Start a new topic

Powershell widget

Hi,


witch user account is the powershell widget using?


I'm doing some testing, and are trying to run a command like this:

invoke-command -computername "ServerName" -scriptblock {netstat}


Best regards


Jan L Dam


Powershell scripts are going to be run by the App pool user account. That account will need to have permissions to what you are trying to accomplish. 


In some cases you may not want to give that account permissions like in the case of pulling information from AD. In that case we advise on a 2 step process. Where you have a scheduled script running to put the data into a txt/csv type of file, then allow the app pool to read that information in and format it the way you want. 


Just figured i would add that to them mix. 

#Store the password in credential#

 

Read-host -assecurestring | convertfrom-securestring | out-file C:\cred.txt

$password = get-content C:\cred.txt | convertto-securestring

$credential = new-object -typename System.Management.Automation.PSCredential -argumentlist "myusername",$pass

 

#Use invoke-command to execute the operation#

 

Invoke-command –computername <server name> -credential $credential –scriptblock {get-service}

 

Reference:

 

Powershell Tip - Storing and Using Password Credentials


https://social.technet.microsoft.com/Forums/en-US/406abcc5-883b-425c-8489-002b0f9394d8/invokecommand-without-manual-entry-of-password?forum=winserverpowershell

Hi,


I found another, not so fun solution to deliver the number they where looking for.


But, @Chris, I don't want to give the app pool user the permissions, but you might consider making it possible to choose another user to run the script, just a suggesting and I don't know if it is possible at all.


@scott, I don't wan't to have a cred file on my serveres, if I can avoid it, but else a great idea, thanks.

It is something we are working on. It is nothing i can promise in the next couple of releases. 


I understand the value here and why it is important.


Chris Malay

Login or Signup to post a comment