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

$null as string instead of verbal from csv

$
0
0

Import-module ActiveDirectory 

Import-CSV "C:\info2.csv" | % {

$User = $_.dname

$OfficePhone = $_.OfficePhone

$MobilePhone = $_.MobilePhone

$departmen = $_.departmen

$Fax = $_.Fax

Set-ADUser $User -OfficePhone $OfficePhone -MobilePhone $MobilePhone -departmen $departmen

# Next PowerShell Command need Quest Add-in

Set-ADUser $User -Fax $Fax -HomePhone $null

Set-QADUser $User -facsimileTelephoneNumber $Fax

}

 

here is some of the csv ,

dname

departmen

OfficePhone

MobilePhone

Fax

someone

BO

 +972-3-xxxxx

$null

 +972-3-xxxxx

 

Normal 0 false false false EN-US X-NONE HE

now the MobilePhone is blank if i leave it blank i get error, and on oder users i just want to wipe there info so i lay the null,

if i just use "Set-ADUser $User -Fax $Fax -HomePhone $null" it work grate but the problame with MobilePhone is that some employed dont have MobilePhone and so have, and power shell aperntly use the $null in csv as a string.

Normal 0 false false false EN-US X-NONE HE

Normal 0 false false false EN-US X-NONE HE


Viewing all articles
Browse latest Browse all 8583

Trending Articles