At my hospital I am trying to write a script to add security when unlocking a user's account. when running this code,
import-module ActiveDirectory
$user = Read-Host -prompt 'User name of Person locked out'
$id = get-aduser $user -properties '*'| select -property employeeNumber
$id outputs as "@{employeeNumber=someNumber}"
is there any way to set the $id to just output 'someNumber'? Thanks in advance!
You can utilize -ExpandProperty 'employeeNumber'
on the Select-Object
cmdlet.
Alternatively:
$id = (Get-ADUser $user -Properties '*').employeeNumber
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.