Last active
August 29, 2015 14:15
-
-
Save torgro/3835d8a4ab878b8556f8 to your computer and use it in GitHub Desktop.
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
function Import-Object | |
{ | |
[cmdletbinding()] | |
Param( | |
[Parameter(Mandatory)] | |
[Hashtable]$KeyValue | |
, | |
[pscredential]$Credential | |
, | |
[string]$Uri | |
) | |
$f = $MyInvocation.InvocationName | |
Write-Verbose -Message "$f - START" | |
Write-Verbose -Message "$f - Getting data" | |
$db = Get-XMLdocument | |
[string]$ObjectID = $KeyValue.ObjectID | |
[string]$ObjectType = $KeyValue.ObjectType | |
[string]$ObjectName = $KeyValue.ObjectName | |
[string]$ObjectValue = $KeyValue.ObjectValue | |
[string]$Operation = $KeyValue.Operation | |
if(-not ($ObjectType -ne "Person" -or $ObjectType -ne "Group")) | |
{ | |
throw "Object type '$ObjectType' not supported" | |
} | |
if($Operation -ne "Update") | |
{ | |
throw "'$Operation' operation on objectID '$ObjectID' cannot complete, the operation is not supported or null" | |
} | |
if(-not $ObjectName) | |
{ | |
throw "ObjectName '$ObjectName' is not supported or null" | |
} | |
[string]$xPath = "//$ObjectType[@ObjectID = '$ObjectID']" | |
Write-Verbose -Message "$f - xPath = $xPath" | |
$obj = $db | Select-Xml -XPath $xPath | |
Write-Verbose -Message "$F - ObjectName = $ObjectName = $ObjectValue" | |
$obj.Node.$ObjectName = $ObjectValue | |
Write-Verbose -Message "$f - Updating global scope variable" | |
Set-Variable -Name xml -Value $db.InnerXml -Scope Global | |
Write-Verbose -Message "$f - END" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment