Avatar of Kelly Garcia
Kelly GarciaFlag for United Kingdom of Great Britain and Northern Ireland

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.

Get-QADComputer | Get-Service -ComputerName $_.computername -Name *xagt*

Open in new window

Powershell

Avatar of undefined
Last Comment
Chris Dent
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Is ComputerName a property returned by Get-QADComputer? It's been years since I've seen Quest, so it could be...
Get-QADComputer | Get-Service -Name *xagt*

Open in new window

The value is picked out because ComputerName accepts pipeline input:
PS> Get-Help Get-Service -Parameter ComputerName

ComputerName <String[]>
...
    Required?                    false
    Position?                    named
    Default value                None
    Accept pipeline input?       True (ByPropertyName)
    Accept wildcard characters?  false

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.
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Kelly Garcia
Kelly Garcia
Flag of United Kingdom of Great Britain and Northern Ireland image

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.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand

Regards,
Kay
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

That's your access rights, not code.
Avatar of Qlemo
Qlemo
Flag of Germany image

... and should be the same when using Chris' code.
Avatar of Kelly Garcia
Kelly Garcia
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

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

Open in new window

WMI is open as yet another option, uses DCOM over RPC, but a different permissions model.
Powershell
Powershell

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

27K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo