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

Parsing an array to a function

$
0
0

Hello,

 

I am wondering if someone can give me a quick hand on a function I am writting which it is not behaving in the way I am expecting.
I want to call this function by doing a (Get-Content .\Users.txt) | Get-ProfilePath
The script works fine but it only gets 1 users ProfilePath. It is not parsing correctly as it would be an array of users.

 

functionGet-ProfilePath {

param (
[Parameter(
Mandatory=$true,
ValueFromPipeline=$true
)]
[String[]]$Users
)

foreach ($userin$Users)
{
$userDN= (Get-ADUser$User).distinguishedName
$userDN
$userInfo= [ADSI]"LDAP://$userDN"
$userINfo
if ($userInfo.TerminalServicesProfilePath ) {$userInfo.TerminalServicesProfilePath | get-oldnavision }
}

}

Viewing all articles
Browse latest Browse all 8583

Trending Articles