Get rid of the $ in your function calls. You are calling your function like a variable so your script is trying to find a global variable instead.
Gavin From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Behalf Of Daniel Ratliff Sent: Tuesday, December 30, 2014 12:28 PM To: powershell@lists.myitforum.com Subject: [powershell] functions, parameters, and scopes, oh my I think I am overcomplicating this, or missing something really obvious. A script I wrote last year stopped working a month or two ago and I have pinpointed the cause. One of the functions cannot be accessed and I believe it is scope related. When I wrote it, I ran across an issue and just put $global: on everything, I should have taken the time to understand each scope and properly write it, but alas I didn't. Now I think it may be causing an issue. Where it fails is at the very bottom in my if statement, $global:printerinstall cannot be found. The ISE also tells me the -printerip parameter on $global:printerlist also cannot be found. Thoughts? Here are the main parts (not the entire script is posted): function global:PrinterList { Param( [string]$global:printerip ) } function global:PrinterInstall { $global:printerlist -printerip $global:dataip } if ($printerarray -eq $null -or $printerarray -eq "") { write-warning "No printers found!" } else { foreach ($port in $printerarray) { if ($port -like "IP_*") { $port = $port.replace("IP_","") $global:dataip = $port write-host "$global:dataip" } elseif ($port -eq $null -or $port -eq "") { write-host "Portname is invalid!" } elseif ($port -notlike "*.*.*.*") { if (Test-Connection $port -count 1 -ErrorAction SilentlyContinue) { $port = (Test-Connection $port -count 1).protocoladdress $global:dataip = $port write-host "$global:dataip" } else { write-error "Portname is invalid!" } } else { $global:dataip = $port write-host "Port: $global:dataip" } $global:printerinstall } } Daniel Ratliff The information transmitted is intended only for the person or entity to which it is addressed and may contain CONFIDENTIAL material. If you receive this material/information in error, please contact the sender and delete or destroy the material/information. ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1 ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1