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

Pipeline Variables

$
0
0

 

How do we assign the current value of one pipeline variable to another?

This works fine for me.

$hash = ((get-content .\hash.txt) -join "`n") | ConvertFrom-StringData

$hash.GetEnumerator() | % { 

$_.value 

}

Now how do I assign each value from the hash table to $_.UserPrincipalName in the following?

$hash = ((get-content .\hash.txt) -join "`n") | ConvertFrom-StringData

$MaxPassAge = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge.days

$DaysToExpire = 25

$hash.GetEnumerator() | % { 

Get-ADUser -SearchBase (Get-ADRootDSE).defaultNamingContext -Filter {(Enabled -eq "True") -and (PasswordNeverExpires -eq "False") } -Properties PasswordLastSet | Select-Object givenname,SamAccountName,UserPrincipalName,@{Name="Expires";Expression={$MaxPassAge -((Get-Date) - ($_.PasswordLastSet)).days}} | Where-Object { $_.UserPrincipalName -eq $_.value } | Where-Object {$_.expires -gt 0 -AND $_.expires -le $DaysToExpire }

}

Any pointers are highly appreciated. Thanks

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles