I am trying to create a powershell script that can set up and configure a windows service on application server
[string]$serviceAct = "myadminact"
New-Item C:\Temp\pas.txt
Set-Content C:\Temp\pas.txt '72233322d113443434343'
New-Item C:\Temp\e.key
Set-Content C:\Temp\e.key '113' (The key is longer I just shortened)
$serviceActPw = Get-Content C:\Temp\pas.txt | ConvertTo-SecureString -Key (Get-Content C:\Temp\e.key)
$credential = New-Object System.Management.Automation.PsCredential($serviceAct,$serviceActPw)
(more script before this line)
#Set up and configuration of service
infOutput("Creating ReportFYI services on $appServer...")
try
{
Invoke-Command -ComputerName $webServer -ArgumentList $folderName,$serviceAct,$serviceActPw -ScriptBlock{
param($folderName,$serviceAct,$serviceActPw)
$serviceActCred = New-Object System.Management.Automation.PSCredential ($serviceAct,$serviceActPw)
New-Service -Name "RW Process x64 - $folderName" -DisplayName "RW Process x64 - $folderName" -Description "RW Process x64 - $folderName" -BinaryPathName "C:\Program Files\FYISoft\$folderName\Process\RWProcess.exe" -Credential $serviceActCred
}
}
catch
{
errorOutput
}
Any help is appreciate it