Powershell Output not showing
Hi all,
I'm a bit of a dabbler/bodger in powershell and by no means any sort of professional. I have the following script which is to take an entered remote computer name, check the graphics card driver version, output the results and and then give the menu choice. I think the script isn't pausing for long enough to output the details from the remote computer. Is there a way to get it to pause to output the details or is there a better way?
Clear-Host
[String]$SiteName = read-host "PC Name"
Do{
Write-host $SiteName (Test-Connection -count 1 $SiteName -quiet)
$strQuit = Read-Host "Do you want to test again? (Y/N)"
}
Until ($strQuit -eq "N")
Get-WmiObject Win32_VideoController -ComputerName $SiteName | select SystemName, Description, DriverVersion
do
{
Write-Host "1: Clone"
Write-Host "2: Extend"
$input = Read-Host "Please make a selection"
switch ($input)
{
'1' {
Invoke-Command -ComputerName $SiteName -ScriptBlock {C:\Windows\System32\DisplaySwitch.exe /clone}
} '2' {
Invoke-Command -ComputerName $SiteName -ScriptBlock {C:\Windows\System32\DisplaySwitch.exe /extend}
}
}
}until ($input -eq 'q')
Answers (1)
Try this below. You almost had it.
This is not the best way to script but if you are learning, its OK. The best method would be to have array feed into a script/code that has all the machines with the desired setting - aiming for full automation.
Anything that waits for a action or sleeps is undesired - keep that in mind when you advance (: