############################################################################### #Variable Assignment ############################################################################### $PowerShellUsername = "DRI_NT1\hyperionIDHere" $PowerShellPasswordFile = "C:\Path\Where\Encrypted\Paasword\Is_stored\PasswordFile.pass" $PlanningComputerName = "ServerNameHere" $PlanningCommand = {Start-Process -FilePath D:\Oracle\Scripts\Hyp_Services_start.bat -Verb RunAs -Wait } ############################################################################### #Create Credential for Remote Session ############################################################################### $PowerShellCredential=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $PowerShellUsername, (Get-Content $PowerShellPasswordFile | ConvertTo-SecureString) ############################################################################### #Create Remote Session Using Credential ############################################################################### $PlanningSession = New-PSSession -ComputerName $PlanningComputerName -credential $PowerShellCredential ############################################################################### #Invoke the Remote Job ############################################################################### $PlanningJob = Invoke-Command -Session $PlanningSession -Scriptblock $PlanningCommand -ErrorAction Stop echo $PlanningJob ############################################################################### #Close the Remote Session ############################################################################### Remove-PSSession -Session $PlanningSession