Hello Experts ,
I am writing one powershell script which has 2 functions , Basically the functions query the WSUS Server information of each client sytem. I want to retun the value of each function and store it in a single CSV File.
Below is my script
$Result = @() Function EMEAWSUSQuery($server , $Result) { $Result += $server+",EMEA SErver" + "`n" Return $Result; } Function USWSUSQuery($server , $Result) { $Result += $server+",US Server" + "`n" Return $Result; } $b = Get-Content C:\servers1.txt [string]$EMEAWSUS = "http://xyz.abc.com:8530" [string]$USWSUS = "http://prq.abc.com:8530" foreach ($server in $b) { try { $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$server) $regkey = $reg.Opensubkey("Software\\Policies\\Microsoft\\Windows\\WindowsUpdate") [string]$WSUSServer = $regkey.GetValue("WUServer") if($WSUSServer -like $EMEAWSUS) { EMEAWSUSQuery ($server,$Result) } elseif($WSUSServer -like $USWSUS) { USWSUSQuery($Sever,$Result) } } Catch { $Result +=$server +", dont have WSUS Entry"+"'n" } } $Result | Out-File C:\Testinggg.csv -Force -Append ASCII
I know I am not using the return value , properly.
I want $Result variable to contain the output of both my function.
Can somebody guide me here?
-Prashant Girennavar
MCSA|MCITP SA|Microsoft Exchange 2003 Blog - http://prashant1987.wordpress.com Disclaimer: This posting is provided AS-IS with no warranties/guarantees and confers no rights.