Hello, I made a simple program that print specified computers in our Domain, sadly there is a problem with returning an object from a function after call. First call does not work, 2nd print same output 2 times. Do you have any idea how to display it in a first run? As far as i know it is a problem that get-ad makes object and objects are not so eazy to return from function.
function MyFunctionOne{
$Computers=(Get-ADComputer -Filter * -Properties MemberOf,description | Where-Object {[STRING]$_.MemberOf -notlike "*GroupName*"} | Select name, Description )
return $Computers
}
function main{
$choice = 0
Import-Module -Global -Name ActiveDirectory
Import-Module -Global -Name Microsoft.PowerShell.Utility // I though It was problem with module so I import it before execute command
do{
$choice = Read-Host
switch($choice){
1 {MyFunctionOne break}
2 {$choice = 0}
}
}while($choice -ne 0)
}
main