![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How can i pass values from external files foreach ($computer in $computernames) { $strQuery = "select * from win32_pingstatus where address = '" + $computer + "'" $wmi = Get-WmiObject -query $strQuery switch ($wmi.statuscode) ## statuscode derived from http://msdn.microsoft.com/en-us/library/aa394350.aspx ## { "0" {write-host $computer.toupper() "`t" "Success";$value ="Success"} "11001" {write-host $computer.toupper() "`t" "Buffer Too Small";$value = "Buffer Too Small"} "11002" {write-host $computer.toupper() "`t" "Destination Net Unreachable";$value = "Destination Net Unreachable"} "11003" {write-host $computer.toupper() "`t" "Destination Host Unreachable";$value = "Destination Host Unreachable"} "11004" {write-host $computer.toupper() "`t" "Destination Protocol Unreachable";$value = "Destination Protocol Unreachable"} "11005" {write-host $computer.toupper() "`t" "Destination Port Unreachable";$value="Destination Port Unreachable"} "11006" {write-host $computer.toupper() "`t" "No Resources";$value="No Resources"} "11007" {write-host $computer.toupper() "`t" "Bad Option";$value="Bad Option"} "11008" {write-host $computer.toupper() "`t" "Hardware Error";$value="Hardware Error"} "11009" {write-host $computer.toupper() "`t" "Packet Too Big";$value="Packet Too Big"} "11010" {write-host $computer.toupper() "`t" "Request Timed Out";$value ="Request Timed Out"} "11011" {write-host $computer.toupper() "`t" "Bad Request";$value="Bad Request"} "11012" {write-host $computer.toupper() "`t" "Bad Route";$value="Bad Route"} "11013" {write-host $computer.toupper() "`t" "TimeToLive Expired Transit";$value="TimeToLive Expired Transit"} "11014" {write-host $computer.toupper() "`t" "TimeToLive Expired Reassembly";$value="TimeToLive Expired Reassembly"} "11015" {write-host $computer.toupper() "`t" "Parameter Problem";$value="Parameter Problem"} "11016" {write-host $computer.toupper() "`t" "Source Quench";$value="Source Quench"} "11017" {write-host $computer.toupper() "`t" "Option Too Big";$value="Option Too Big"} "11018" {write-host $computer.toupper() "`t" "Bad Destination";$value="Bad Destination"} "11032" {write-host $computer.toupper() "`t" "Negotiating IPSEC";$value="Negotiating IPSEC"} "11050" {write-host $computer.toupper() "`t" "General Failure";$value="General Failure"} default {write-host $computer.toupper() "`t" "Ping request could not find host. Please check the name and try again";$value="Ping request could not find host. Please check the name and try again"} } =================================================================================================== On the whole switch statement, i can put as statuscode.ps1 and subsitute as ...\statuscode.ps1 in my script. Therefore it becomes like this foreach ($computer in $computernames) { $strQuery = "select * from win32_pingstatus where address = '" + $computer + "'" $wmi = Get-WmiObject -query $strQuery ...\statuscode.ps1 } However on the *main* script, i wish to retrieve the $value back, as i want to include in other variables. How do i READ the $value in my main script ? |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Transfer files between two external drives? | Vista General | |||
| Copying Files to External Drive | Vista file management | |||
| import msg.files from external harddisk | Vista mail | |||
| How to pass values from script to external batch files | PowerShell | |||
| Metadata in external file? Avi and .mp4 files | Vista file management | |||