Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate Granfeldt PowerShell Management Agent Schema File - CSV File. Supporting blog post can be located here https://blog.darrenjrobinson.com/automate-the-generation-of-a-granfeldt-powershell-management-agent-schema-definition-file/
# CSV Exported from IdentityNow Source
$csv = Get-Content -Path "C:\path\to\file\file.csv"
# Get header row and split on ,
$columns = $csv[0].Split(",")
# Generate Output Schema.ps1
$output = @()
$output += "`$obj = New-Object -Type PSCustomObject"
$output += "`$obj | Add-Member -Type NoteProperty -Name `"Anchor-YourAnchorATTR|String`" -Value `"`""
$output += "`$obj | Add-Member -Type NoteProperty -Name `"objectClass|String`" -Value `"YourObjectClass`""
foreach ($obj in $columns) {
$output += "`$obj | Add-Member -Type NoteProperty -Name `"$($obj)|string`" -Value `"string" + "`""
}
$output += "`$obj"
$output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment