Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Service Configuration

$
0
0

Hi All,

I am working on a script to reconfigure services on a Windows machine using PowerShell.

The first script is used to create the credentials.  Everything is successful BUT the password.

Can this be done using PowerShell?

Thanks.

##Set working directory

 

 

 

 

 

 

 

$curdir

 

 

=Split-Path-parent$MyInvocation.MyCommandDefinition

cd

 

 

$curdir

##Configure Service

$User

 

 

='cast\localservice2'

$SecurePassword

 

 

=get-contentC:\scripts\encrypted.txt|ConvertTo-SecureString

$UserCred

 

 

=New-ObjectSystem.Management.Automation.PSCredential ($User,$SecurePassword)

.\Ntrights.exe

 

 

+rSeServiceLogonRight-u$User

sc.exe

 

 

config"WIMASvc"obj=$Userpassword=$SecurePassword

sc.exe

 

 

start WIMASvc


Viewing all articles
Browse latest Browse all 6937

Trending Articles