Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Out-GridView command assitance

$
0
0

Hi All,

I wrote script to look for USB stick name and show that in out-gridview with its status

Problem is that out-gridview closes window when script finishes. Currently powershell i using is 1.0 so i can't utilize Passthru property. 

Please can someone help me to hold out-gridview windows till user closes it.

Here is the script

$machinename="NMDPR"#remote machine computer names

$range= 1..3

foreach ($valin$range)

{

$machine=$machinename+$val

$value=Get-WmiObject win32_PNPEntity -ComputerName$machine | ForEach-Object {$_.caption}



if($value-eq"Kingston")

{

$Connected="Connected"

}

else

{

$Connected="Not Connected"

}

$Results=New-Objectsystem.object

$Results | Add-member-type Noteproperty -name Wk -value$Machine

$Results | Add-member-type Noteproperty -name stick -value$Connected

$Status+=$Results

}

Return$Status | Out-GridView

Read-Host-Prompt"Press enter to exit"

Viewing all articles
Browse latest Browse all 6937

Trending Articles