Kelly Garcia
asked on
Quest Powershell code
Hi All,
I have written the code below however it does not work. please can someone explain why it doesn't work as I am trying to advance in powershell.
I have written the code below however it does not work. please can someone explain why it doesn't work as I am trying to advance in powershell.
Get-QADComputer | Get-Service -ComputerName $_.computername -Name *xagt*
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Qlemo,
I have tried this however I get the following error:
Get-Service : Cannot open Service Control Manager on computer 'LP-LON-1573$'. This operation might require other
privileges.
At line:1 char:31
+ ... p-lon-1573 | Get-Service -ComputerName {$_.computername} -Name *xagt*
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Service], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationExc eption,Mic rosoft.Pow erShell.Co mmands.Get ServiceCom mand
Regards,
Kay
I have tried this however I get the following error:
Get-Service : Cannot open Service Control Manager on computer 'LP-LON-1573$'. This operation might require other
privileges.
At line:1 char:31
+ ... p-lon-1573 | Get-Service -ComputerName {$_.computername} -Name *xagt*
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Service], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationExc
Regards,
Kay
That's your access rights, not code.
... and should be the same when using Chris' code.
ASKER
the account has domain admin rights and also this my own laptop, the lp-lon-1573 and I am clearly added as a admin on it
Something else perhaps. But it's not the code. You might work around it, for example by using remoting instead of RPC.
Invoke-Command { Get-Service *xagt* } -ComputerName lp-lon-1573
WMI is open as yet another option, uses DCOM over RPC, but a different permissions model.
Open in new window
The value is picked out because ComputerName accepts pipeline input:Open in new window
The "ByPropertyName" means the input object (returned by Get-QADComputer) must have a property with a corresponding name. If it does, the parameter will automatically fill itself in.