CSV:
BackupGpoName,BackupId,GPOName,path "GPO1",11111111-2222-3333-444444444444,"GPO1","C:\BackupGPO" "GPO2",78888888-1222-4555-8777-123456789123,"GPO1","C:\BackupGPO"
Script:
$csv = Import-Csv -Path "C:\gpotest.csv" -Header BackupGpoName, BackupId, gponame, Path
$csv | ForEach-Object {
$params = @{
BackupGpoName = $_.BackupGpoName
BackupId = $_.backupid
TargetName = $_.gponame
Path = $_.path
}
$params.$type = $true
Import-Gpo @params -CreateIfNeeded
}
But I get the error:
Foreach-Object : Cannot bind parameter 'BackupId'. Cannot convert value "BackupId" to type "System.Guid". Error: "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)." At line:2 char:10 + $csv | Foreach-Object { + ~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [ForEach-Object], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ForEachObjectCommand
-Header
. Your CSV file already has a header line in it. – Bill_Stewart