SHARE
TWEET

VPN_Profile_Device.ps1

a guest Sep 13th, 2018 839 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Param(
  2. [string]$xmlFilePath,
  3. [string]$ProfileName
  4. )
  5.  
  6. $a = Test-Path $xmlFilePath
  7. echo $a
  8.  
  9. $ProfileXML = Get-Content $xmlFilePath
  10.  
  11. echo $XML
  12.  
  13. $ProfileNameEscaped = $ProfileName -replace ' ', '%20'
  14.  
  15. $Version = 201606090004
  16.  
  17. $ProfileXML = $ProfileXML -replace '<', '&lt;'
  18. $ProfileXML = $ProfileXML -replace '>', '&gt;'
  19. $ProfileXML = $ProfileXML -replace '"', '&quot;'
  20.  
  21. $nodeCSPURI = './Vendor/MSFT/VPNv2'
  22. $namespaceName = "root\cimv2\mdm\dmmap"
  23. $className = "MDM_VPNv2_01"
  24.  
  25. $session = New-CimSession
  26.  
  27. try
  28. {
  29. $newInstance = New-Object Microsoft.Management.Infrastructure.CimInstance $className, $namespaceName
  30. $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("ParentID", "$nodeCSPURI", 'String', 'Key')
  31. $newInstance.CimInstanceProperties.Add($property)
  32. $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("InstanceID", "$ProfileNameEscaped", 'String', 'Key')
  33. $newInstance.CimInstanceProperties.Add($property)
  34. $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("ProfileXML", "$ProfileXML", 'String', 'Property')
  35. $newInstance.CimInstanceProperties.Add($property)
  36.  
  37. $session.CreateInstance($namespaceName, $newInstance)
  38. $Message = "Created $ProfileName profile."
  39. Write-Host "$Message"
  40. }
  41. catch [Exception]
  42. {
  43. $Message = "Unable to create $ProfileName profile: $_"
  44. Write-Host "$Message"
  45. exit
  46. }
  47. $Message = "Complete."
  48. Write-Host "$Message"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top