I am new to powershell and need help. My first script to work automates new and named users in the AD environment.
A CSV dump will be executed once a day from our Peoplesoft system. I use Import-CSVand create 3 arrays (new, terms and processed).
The problem I ran into is combining the three arrays when I go through all the users and try to get them back to the file. The code is broken into lines $New += $Term. I believe that this is due to the fact that in my test file there is only 1 entry for each type of user (new, thermal and processed) (I know, add more users and hellip; I can’t. This can be a real result for any particular day ) The following is sample code:
$c = Get-Credential
$e = Get-Date -format M/d/yyyy
$File = "c:\users\nmaddux\desktop\adduserstuff\test.csv"
$New = @()
$Term = @()
$Procd = @()
$New = Import-Csv $File | Where-Object {
$_.TermDate -eq "" -and $_.LastName -ne "" -and $_.Processdate -eq ""
}
$Term = Import-Csv $File | Where-Object {
$_.TermDate -ne "" -and $_.Processdate -eq "" -and $_.TermDate -le $e
}
$Procd = Import-Csv $File | Where-Object { $_.Processdate -ne "" }
If ($New -ne $NULL -and $Term -ne $NULL) {
}
$new += $term
$new += $Procd
$new | Export-Csv $file -NoTypeInformation -ErrorAction SilentlyContinue
, , .
error - , [System.Management.Automation.PSObject] "op_Addition".