Last active
November 17, 2018 21:38
-
-
Save darrenjrobinson/541c62c92f234da19e5d36ab380f2b9d to your computer and use it in GitHub Desktop.
Generate Granfeldt PowerShell Management Agent Schema File - Workday User. Supporting blog post can be located here https://blog.darrenjrobinson.com/automate-the-generation-of-a-granfeldt-powershell-management-agent-schema-definition-file/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download and install the Workday PowerShell Module from | |
# https://github.com/treestryder/powershell_module_workdayapi | |
Import-Module WorkdayApi | |
Set-WorkdayCredential | |
Set-WorkdayEndpoint -Endpoint Human_Resources -Uri 'https://<SERVICE>.workday.com/ccx/service/<TENANT>/Human_Resources/v30.2' | |
Save-WorkdayConfiguration | |
$object = Get-WorkdayWorker -WorkerType Employee_ID -WorkerId 12345 -IncludeWork -IncludePersonal -IncludeDocuments | |
$Attributes = $object | Get-Member -MemberType NoteProperty | |
$schema = @() | |
foreach ($attr in $Attributes) { | |
$d = $null # attr definition | |
$type = $null # attr type | |
$d = $attr.Definition.Split(" ") | |
if ($attr.Definition.StartsWith("string $($attr.Name)")) {$type = "string"} | |
if ($d[0] -eq "System.Nullable[bool]") {$type = "boolean"} | |
if ($d[0] -eq "System.Nullable[datetime]") {$type = "datetime"} | |
if ($d[0].StartsWith("System.Collections.Generic.List")) {$type = "multivalue"} | |
if ($d[0].StartsWith("System.Collections.Generic.Dictionary")) {$type = "multivalue"} | |
switch ($type) { | |
"string" {$schema += "$($d[1].substring(0,$d[1].indexof("=")))|$($d[0])`" -Value `"string" + "`""} | |
"boolean" {$schema += "$($d[1].substring(0,$d[1].indexof("=")))|boolean`" -Value `$true"} | |
"datetime" {$schema += "$($d[1].substring(0,$d[1].indexof("=")))|string`" -Value `"string`""} | |
"multivalue" {$schema += "$($d[$d.Length-2])|String[]`" -Value (`"`",`"`")"} | |
} | |
} | |
# 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 $schema) { | |
$output += "`$obj | Add-Member -Type NoteProperty -Name `"$($obj)" | |
} | |
$output += "`$obj" | |
$output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment