Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Param(
- [string]$xmlFilePath,
- [string]$ProfileName
- )
- $a = Test-Path $xmlFilePath
- echo $a
- $ProfileXML = Get-Content $xmlFilePath
- echo $XML
- $ProfileNameEscaped = $ProfileName -replace ' ', '%20'
- $Version = 201606090004
- $ProfileXML = $ProfileXML -replace '<', '<'
- $ProfileXML = $ProfileXML -replace '>', '>'
- $ProfileXML = $ProfileXML -replace '"', '"'
- $nodeCSPURI = './Vendor/MSFT/VPNv2'
- $namespaceName = "root\cimv2\mdm\dmmap"
- $className = "MDM_VPNv2_01"
- $session = New-CimSession
- try
- {
- $newInstance = New-Object Microsoft.Management.Infrastructure.CimInstance $className, $namespaceName
- $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("ParentID", "$nodeCSPURI", 'String', 'Key')
- $newInstance.CimInstanceProperties.Add($property)
- $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("InstanceID", "$ProfileNameEscaped", 'String', 'Key')
- $newInstance.CimInstanceProperties.Add($property)
- $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("ProfileXML", "$ProfileXML", 'String', 'Property')
- $newInstance.CimInstanceProperties.Add($property)
- $session.CreateInstance($namespaceName, $newInstance)
- $Message = "Created $ProfileName profile."
- Write-Host "$Message"
- }
- catch [Exception]
- {
- $Message = "Unable to create $ProfileName profile: $_"
- Write-Host "$Message"
- exit
- }
- $Message = "Complete."
- Write-Host "$Message"
Advertisement
Add Comment
Please, Sign In to add comment