Changing AD-User Properties
hey there,
i'm trying change officephone properties..
my script far:
$user = get-aduser -filter * -searchbase "ou=,ou=,ou=,ou=,dc=,dc=" -properties officephone
foreach ($line in $user) {
$phone = $line.officephone
if($line.officephone -like '*8900*'){
}
else{
$line=$line.officephone -replace " ","" | set-aduser -officephone $line.officephone
}
}
so want replace every space in phonenumbers " " "" im getting érror
set-aduser : cannot find object identity:
can anybody me?
thanks in advance
your variable name bit odd. :-p but think you'll either want
$line.officephone = $line.officephone -replace ' ', ''
set-aduser -instance $line
or
$line | set-aduser -officephone ($line.officephone -replace ' ', '')
i haven't tested those, both should work. use whichever prefer.
john h. moe
Windows Server > Windows PowerShell
Comments
Post a Comment