Skip Blank Values in Import-CSV


i attempting mass import of user attributes (phone number, address, city, state, zip code, title, company). goes until hit blank value in csv. here powershell script trying use.

import-csv ia-test2.csv |  foreach-object {      $record = $_        get-aduser -ldapfilter "(samaccountname=$($record.samaccountname))" |      set-aduser -city $record.l -postalcode $record.postalcode -officephone $record.officephone -company $record.company -streetaddress $record.streetaddress -title $record.title  }

how can modify skip blank values?

typo.  i missing  last $ in 

{ $params.$property = $_.property }

updated script:

$properties = @(     'city',     'postalcode',     'officephone',     'company',     'streeaddress',     'title'     )  import-csv ia-test2.csv | foreach-object {     $params =  @{}     foreach ($property in $properties)      {        if ($_.$property)           { $params.$property = $_.$property }      }      get-aduser -ldapfilter "(samaccountname=$($_.samaccountname))" |     set-aduser @params }


[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file