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

Need help with syntax please

$
0
0

Trying to figure out how this works because i have a few scripts that have problems - most likely to bad syntax that is not being caught.... 

Reading computer CN out of Active Ditectory, feeding it into the For loop and trying to create a variable using hash table that is within a function. The $Result variable is supposed to contain the Computer name and a word hello. But I cant seem to get the logic correctly for it to return the computer name....

 

Function SetOutputVariable ($Computer){
     $SQLProperties=@{'ComputerName' = $Computer.CN
                                   'Message' = "hello"
                                  }
Return $SQLProperties
}

$Result =`
Foreach ($Computer in $Computers){
            SetOutputVariable -ComputerName $Computer.CN
            New-Object -TypeName psobject -Property $SQLProperties
}

$Result | FT

 

 

Thank you for your help!


Viewing all articles
Browse latest Browse all 6937

Trending Articles