How to get the service status for a remote computer that requires a username and password to log in?
I am trying to find a solution using the following code:
$serviceStatus = get-service -ComputerName $machineName -Name $service
The default syntax for the command is get-service:
Parameter Set: Default
Get-Service [[-Name] <String[]> ] [-ComputerName <String[]> ] [-DependentServices] [-Exclude <String[]> ] [-Include <String[]> ] [-RequiredServices] [ <CommonParameters>]
Parameter Set: DisplayName
Get-Service -DisplayName <String[]> [-ComputerName <String[]> ] [-DependentServices] [-Exclude <String[]> ] [-Include <String[]> ] [-RequiredServices] [ <CommonParameters>]
Parameter Set: InputObject
Get-Service [-ComputerName <String[]> ] [-DependentServices] [-Exclude <String[]> ] [-Include <String[]> ] [-InputObject <ServiceController[]> ] [-RequiredServices] [ <CommonParameters>]
It has no option for username and password.
source
share