There is not a way to specify a "run as administrator" option to the remote shell. I don't think it's an Ansible or pywinrm issue; I simply don't see a way to specify that option when creating a remote shell ( http://msdn.microsoft.com/en-us/library/cc251739.aspx).
Your issue may be related to the "second hop" problem, where it's not allowing your credentials to be used by Invoke-Command: http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/14/enable-powershell-quot-second-hop-quot-functionality-with-credssp.aspx I can reproduce it by running the following as a script: Invoke-Command -ComputerName . { Write-Host "moo" } I'm not quite sure what the fix would be at the moment -- suggestions welcome from any PowerShell experts lurking here. On Wed, Sep 24, 2014 at 10:44 AM, Michael Perzel <[email protected]> wrote: > From here http://technet.microsoft.com/en-us/library/hh849719.aspx > > My problem is this requirement > > - > > On Windows Vista, and later versions of Windows, to use the > *ComputerName* parameter of *Invoke-Command* to run a command on the > local computer, you must open Windows PowerShell with the "Run as > administrator" option. > > > On Wednesday, September 24, 2014 9:33:42 AM UTC-5, Michael Perzel wrote: >> >> I am working to automate our deployment process with ansible but am >> running into a permissions issue. I have a playbook that uses the raw >> module to call a deploy.ps1 file that is on a remote windows server. This >> deploy.ps1 file does some work and then calls an install.ps1 command using >> the following syntax "Invoke-Command -ComputerName $server -filepath >> $from\install.ps1 -argumentlist $version,$siteName" The problem is >> install.ps1 needs to be run as administrator in order to work (it makes >> some changes to IIS). I can run deploy.ps1 (and install.ps1) from an >> administrator powershell window but they fail when I run them from a >> non-admin powershell window. >> >> Is there a way to tell the raw command to run the powershell as admin? >> >> Copied below is the error message. >> >> "stderr": "[localhost] Connecting to remote server localhost failed with >> the following \r\nerror message : Access is denied. For more information, >> see the \r\nabout_Remote_Troubleshooting Help topic.\r\n + >> CategoryInfo : OpenError: (localhost:String) [], PSRemotingTran >> \r\n sportException\r\n + FullyQualifiedErrorId : AccessDenied, >> PSSessionStateBroken\r\n", >> "stdout": "\nDeploying EdgeTestTool version:532 to servers: >> localhost\n\tCopying files to localhost\n\nFile copy complete. Starting >> install\n\tInstalling on remote server localhost in site Default Web >> Site\nC:\\surescripts\\edge\\532\\archive\\EdgeTestTool. >> Web\\obj\\x64\\Debug\\Package\\PackageTmp, 532, Default Web >> Site\r\n\nDone Deploying EdgeTestTool version:532 to servers: >> localhost\n\n", >> >> -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/292dd8e7-49e7-4cb4-8826-1df1bd11c245%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/292dd8e7-49e7-4cb4-8826-1df1bd11c245%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAH%2BKTJ4-5wV2JnhebaJE7R56wapm6k9je1C2mhJeLP4QEo-5nQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
