Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Export powershell changes to csv format

$
0
0

I am running this script to add all employee IDs into my active directory 

>> Import-Module ActiveDirectory
>> $Users = Import-Csv -Path C:\excelfiles\importtest.csv
>> Get-Content -Path C:\excelfiles\importtest.csv | ft
>> sleep 10
>> foreach ($User in $Users)
>> {
>> Set-ADUser -identity $User.SamAccountName -replace @{"employeeID" = $User.employeeID} -verbose
>> } 
>> $results | Export-Csv -path c:\excelfiles\export.csv

The last part of it is my attempt to pull out the results into a csv file but no luck, it exports the file but with no data. Any idea of what im doing wrong? Ive also tried it with the script below was and same results.....

>>Import-Module ActiveDirectory
>>$Users = Import-Csv -Path C:\excelfiles\importtest.csv
>>Get-Content -Path C:\excelfiles\importtest.csv | ft
>>sleep 10
>>foreach ($User in $Users)
>>{
>>Set-ADUser -identity $User.SamAccountName -replace @{"employeeID" = $User.employeeID} -verbose | Export-Csv -path >>C:\excelfiles\export.csv -Append
>>}




Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>