저는 PowerShell을 처음 사용하여 도움이 필요합니다. 내 첫 번째 스크립트는 광고 환경에서 신규 사용자 및 사용자를 자동화하는 것입니다.Powershell - 배열 조합
CSV 덤프는 Peoplesoft 시스템에서 매일 한 번 수행됩니다. Import-CSV
을 사용하고 3 개의 배열 (new, term 및 processed)을 만듭니다.
내가 가지고있는 문제는 일단 모든 사용자를 반복하고 파일에 다시 넣으 려하면 3 개의 배열을 결합하는 것입니다. 코드는 $New += $Term
줄에서 나옵니다. 이 사실은 테스트 파일에 각 사용자 유형 (신규, 용어 및 처리 된)의 레코드가 1 개 밖에 없다는 사실에 기인한다고 생각합니다. (필자는 더 많은 사용자 및 hellip을 추가 할 수 있습니다. 특정 일). 아래 샘플 코드는 다음과 같습니다.
#Get Credentials from user
$c = Get-Credential
#Get Date for $Term array population
$e = Get-Date -format M/d/yyyy
#Set file location and variable for said file
$File = "c:\users\nmaddux\desktop\adduserstuff\test.csv"
#Import record sets for New and Term users
$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 "" }
#Process both new and term users provided there are records to process for each
If ($New -ne $NULL -and $Term -ne $NULL) {
# Some code to process users
}
$new += $term
$new += $Procd
$new | Export-Csv $file -NoTypeInformation -ErrorAction SilentlyContinue
따라서 결과는 부분적으로 만 내보내집니다.
오류 - [System.Management.Automation.PSObject]에 'op_Addition'이라는 메서드가 없기 때문에 메서드 호출이 실패했습니다.
'$ New + = $ Term' 그리고 그 줄은 어디에 있습니까? – aquinas
코드 및 오류 진술을 추가했습니다 ... 사과드립니다. – user2077056