Run a PowerShell script with Administrator privileges through NAnt -


I am currently building an automated script which will deploy the SharePoint Web Parts. The counting code for this process is: -

  & lt; Email echo = "deployment solution" /> & Lt; Exec failonerror = "true" program = "$ {powershell.exe}" & gt; & Lt; Arg value = "- noprofile" /> & Lt; Arg value = "- nologo" /> & Lt; Arg value = "- non-active" /> & Lt; Arg value = "- command" /> & Lt; Arg value = "& amp; quot; and amp; apos; $ {deploysolutions.ps1} & apos; apos; $ {solutionconfiguration.xml} & amp; apo; & quot;" /> & Lt; / Executive & gt;   

Where $ {deploysolutions.ps1} is the script to run and $ {solutionconfiguration.xml} is an argument to pass a script.

This works fine when running on my local machine when I try to run it on my SharePoint Development Server through cruise control, then I go into the permissions errors. I have verified that there are necessary conditions in the credentials to be used. I think the error in the build log is: -

  [exec] Deployment-solution: Unable to add solution MyWebParts.wsp   

which is the error I Put in the PowerShell script

  {Write - host "add solution" name-add-SPSolution -LiteralPath $ path -rerence start-sleep-seconds 60 # close as above } Hold {write error "unable to add name $ solution" throw "solution $ name could not be added"}   

However The credentials go the same way, when the Administrators walk through the PowerShell console.

Is there any way I can call NAT Call to run PowerShell as Administrator? I did not try the following: -

  1 & lt; Arg value = "initiation forces - web run - filepath & amp; quot; -file $ {deploysolutions.ps1} & amp; quot; -gram list & amp; apos; $ {solutionconfiguration.xml} & apos; " /> 2. & lt; Arg value = "& amp; quot; initiation forces - web run & amp; apos; $ {deploysolutions.ps1} & amp; apos; $ {solutionconfiguration.xml} & apo; & quot;" / & Gt; 3. & lt; Arg value = "& amp; apos; start-up powers-web races" & apos; " /> & Lt; Arg value = "& amp; quot; and amp; apos; $ {deploysolutions.ps1} & apos; apos; $ {solutionconfiguration.xml} & amp; apo; & quot;" />   

I have also tried to execute the administrator via PowerShell script, with any success, do anyone have any ideas?

Do you call PowerShells in command run? Such as Runas / user: adminuser powershell.exe

in your exec statement?

Comments