I have a problem with creating a script in windows powershell.
So far I was able to find and list services that contain a given string of characters, but I have an assignment problem with RequiredService to each of the services.
This is my code
$characters = Read-Host "Enter a character string to appear in the service"
$name = get-service -name *$characters*
For($i=0; $i -lt $name.Count; $i++)
{
Write-Host $name[$i]
$Required = get-service -RequiredServices $name[$i]
For($j=0; $j -lt $Required.Count; $j++)
{
Write-Host " "$Required[$j]
}
}
exit 0
and this is a problem
get-service : Cannot find any service with service name 'System.ServiceProcess.ServiceController'.
I have no idea why each service, despite being displayed well, is further otherwise as 'System.ServiceProcess.ServiceController'
Edit:
I changed line 6
$Required = get-service -RequiredServices *($name[$i])
,but still the script doesn't work.
Get-Service : A positional parameter cannot be found that accepts argument 'XboxNetApiSvc'.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…