-1
PowerShellコードを実行すると、以下のエラーが発生します。私はそれを全く理解できません。私はファイルの場所の名前と関係があるかどうかわからない。Powershellエラー
Import-Csv : Cannot bind parameter 'Delimiter'. Cannot convert value "CSV" to type "System.Char". Error: "String must be exactly one character long."
At line:4 char:60
+ ... GroupList = Import-CSV C:\Users\eh3599\Desktop\Powershell CSV Test\Te ...
+ ~~~
+ CategoryInfo : InvalidArgument: (:) [Import-Csv], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ImportCsvCommand
スクリプトソース:
set-executionpolicy unrestricted
Import-Module ActiveDirectory
$GroupList = Import-CSV C:\Users\eh3599\Desktop\Powershell CSV Test\Test2-TestOutput1.csv -header GroupName,Domain | Select GroupName,Domain
$Table = @()
$Record = @{}
foreach ($Group in $GroupList) {
If ($Group.Domain -Eq "a") {$DomainPath = "a.corp"}
If ($Group.Domain -Eq "x") {$DomainPath = "x.corp"}
If ($Group.Domain -Eq "y") {$DomainPath = "y.com"}
If ($Group.Domain -Eq "b") {$DomainPath = "b.com"}
#Get-ADGroupMember command with -Recursive switch includes only object type users with members of nested groups
$GroupMembership = Get-ADGroupMember -identity $Group.GroupName -Server $DomainPath -Recursive | select SamAccountName, Name, objectClass, distinguishedname
#Get-ADGroupMember command without -Recursive switch includes both User and Group objects but no membership of nested groups
#$GroupMembership = Get-ADGroupMember -identity $Group.GroupName -Server $DomainPath | select SamAccountName, Name, objectClass, distinguishedname
foreach ($GroupMember in $GroupMembership) {
$Record."Account Name" = $GroupMember.samaccountname
$Record."Full Name" = $GroupMember.name
$Record."ObjectClass" = $GroupMember.objectClass
$Record."Object DistinguishedName" = $GroupMember.DistinguishedName
$Record."Group Name" = $Group.GroupName
$Record."Group Domain" = $Group.Domain
$objRecord = New-Object PSObject -property $Record
$Table += $objrecord
}
}
$Table | export-csv "C:\Users\eh3599\Desktop\Powershell CSV Test\$(get-date -f yyyy-MM-dd-hh-mm-ss)-ADGroupMembers.csv" -NoTypeInformation
あなたのパスが引用符で囲まれていることを確認してくださいインポート。 'Import-CSV C:¥Users¥eh3599¥Desktop¥Powershell CSV Test¥Test2-TestOutput1.csv'あなたのインポートパスには引用符がないので、何もロードされません。 –
がクロージャー/タイプミスのためにフラグ付けされました –
@JasonSnell完全には正しくありません。これはデリミタの位置引数に 'CSV'をバインドしており、そのパスは' C:\ Users \ eh3599 \ Desktop \ Powershell'としか解釈されませんので、 'Powershell'というファイルを見つけようとしていて、' CSV' hah – TheIncorrigible1