when i run this powershell script i have to manually feed a parameters!! is there is any way toh automate that step.
this is the script
>
param (
[Parameter(Mandatory=$true)]
[string] $wlidsvc,
[string] $Action,
[string] $ServiceStatus,
)
Checks if wlidsvc exists and provides stop
function CheckMyService ($wlidsvc)
{
if (Get-Service $ wlidsvc -ErrorAction SilentlyContinue)
{
# $ServiceStatus =(Get-Service -Name $S wlidsvc).Status
Write-Host $ wlidsvc "-" $stop
}
else
{
Write-Host "$ wlidsvc not found"
}
}
#Condition if user wants to start a service
elseif ($Action -eq 'Start')
{
if ((Get-Service -Name $ wlidsvc).Status -eq 'Running')
{
Write-Host $ wlidsvc "already running!"
}
elseif ((Get-Service -Name $ wlidsvc).Status -eq 'Stopped')
{
Write-Host $ wlidsvc "is stopped, preparing to start..."
Get-Service -Name $ wlidsvc | Start-Service -ErrorAction SilentlyContinue
CheckMyService $ wlidsvc
}
else
{
Write-Host $ wlidsvc "-" $start
}
}
