Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Start service using windows domain account

$
0
0

Hi i am trying to write a powershell script which starts ReportServer service using a windows domain account. Below is what i have got so far:

 $username = "HPA\wms_sql"

$password = cat C:\securestring.txt | convertto-securestring
$cred = new-object System.Management.Automation.PSCredential $username,$password

Start-Service "SQL Server Reporting Services (MSSQLSERVER)" -credential $cred

Everytime i run this i keep getting the error:

Start-Service : A parameter cannot be found that matches parameter name 'credential'.
At line:12 char:72
+ Start-Service "SQL Server Reporting Services (MSSQLSERVER)" -credential <<<<  $cred
    + CategoryInfo          : InvalidArgument: (:) [Start-Service], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.StartServiceCommand

I cannot figure out what i am doing wrong, any help is much appreciated. Am i putting the -credential argument in the wrong place?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>