Score:0

Creation of a windows service with credentials powershell

in flag
Kim

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.