Created
September 2, 2016 17:07
-
-
Save jcoconnor/7c4c23fd3e2849c2d3899428fc063b81 to your computer and use it in GitHub Desktop.
Latest Win-2016 gist
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
==> windows-2016rtm-x86_64-vmware-vsphere-cygwin: Restarting Machine | |
==> windows-2016rtm-x86_64-vmware-vsphere-cygwin: Waiting for machine to restart... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: A system shutdown is in progress.(1115) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: WINPUPP-QLDS1AT restarted. | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: #< CLIXML | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs> | |
==> windows-2016rtm-x86_64-vmware-vsphere-cygwin: Machine successfully restarted, moving on | |
==> windows-2016rtm-x86_64-vmware-vsphere-cygwin: Uploading ../../manifests/windows => C:\Packer\puppet\modules | |
==> windows-2016rtm-x86_64-vmware-vsphere-cygwin: Uploading files/win-2016tp5-x86_64-std.pp => C:\Packer\puppet\win-2016tp5-x86_64-std.pp | |
==> windows-2016rtm-x86_64-vmware-vsphere-cygwin: Provisioning with Powershell... | |
==> windows-2016rtm-x86_64-vmware-vsphere-cygwin: Provisioning with shell script: /var/folders/gt/yl3fzq4j6w7f0f9kgtwxr52w0000gn/T/packer-powershell-provisioner336897524 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Disabling Hibernation... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Found Modules directory C:\Packer\puppet\modules | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Installing the puppetlabs-powershell Version 1.0.6 module from the Forge... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: Preparing to install into C:/Packer/puppet/modules ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: Downloading from https://forgeapi.puppetlabs.com ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Info: Resolving dependencies ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Info: Preparing to install ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: Installing -- do not interrupt ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: C:/Packer/puppet/modules | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: └── puppetlabs-powershell (v1.0.6) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Module puppetlabs-powershell installed | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Installing the puppetlabs-registry (latest version) module from the Forge... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: Preparing to install into C:/Packer/puppet/modules ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: Downloading from https://forgeapi.puppetlabs.com ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Info: Resolving dependencies ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Info: Preparing to install ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: Installing -- do not interrupt ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: C:/Packer/puppet/modules | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: └─┬ puppetlabs-registry (v1.1.3) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: └── puppetlabs-stdlib (v4.12.0) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Module puppetlabs-registry installed | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Installing the puppetlabs-stdlib (latest version) module from the Forge... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: Preparing to install into C:/Packer/puppet/modules ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: Module puppetlabs-stdlib 4.12.0 is already installed. | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Module puppetlabs-stdlib installed | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Loading Default User hive to HKLM\DEFUSER... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: The operation completed successfully. | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Puppet Manifest Processing Starting | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Applying win-2016tp5-x86_64-std.pp. Attempt 1 of 20 ... | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Info: Loading facts | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: Compiled catalog for winpupp-qlds1at.localdomain in environment production in 0.75 seconds | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Info: Applying configuration version '1472835792' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: /Stage[main]/Windows_template::Local_group_policies/File[c:/crash_dumps]/ensure: created | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: /Stage[main]/Windows_template::Configure_services/Service[Audiosrv]/enable: enable changed 'manual' to 'false' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: /Stage[main]/Windows_template::Configure_services/Service[wuauserv]/enable: enable changed 'manual' to 'false' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Error: param() | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # script-header.ps1 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $ErrorActionPreference = 'Stop' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $VerbosePreference = 'Continue' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Get-GPTIniContents { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptIniPath = "$($env:systemroot)\system32\GroupPolicy\gpt.ini" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Default if gpt.ini does not exist | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptContents = @('[General]','Version=0') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (Test-Path -Path $gptIniPath) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptContents = Get-Content $gptIniPath | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { Write-Verbose "$gptIniPath did not exist. Using default"} | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return $gptContents | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Set-GPTIniContents([string[]]$value) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptIniPath = "$($env:systemroot)\system32\GroupPolicy\gpt.ini" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Writing $gptIniPath" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $value | Out-File -FilePath $gptIniPath -Encoding ascii -Force -Confirm:$false | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return $true | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Invoke-IncrementGPTVersion { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Get the current gpt.ini version | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Get-GPTIniContents | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "Version=(\d+)$") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentGPVersion = [long]$matches[1] | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Current GP version is $currentGPVersion" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Incrementing $PolicyType version by one" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Ref: https://blogs.technet.microsoft.com/grouppolicy/2007/12/14/understanding-the-gpo-version-number/ | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Ref: https://technet.microsoft.com/en-us/library/cc978247.aspx | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # User policy is upper 16bits | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Machine policy is lower 16bits | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($PolicyType.ToUpper() -eq 'USER') { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentGPVersion += 0x00010000 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentGPVersion += 0x00000001 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "New GP version is $currentGPVersion" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Updating Version=$($currentGPVersion)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $newGPTContent = (Get-GPTIniContents | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "Version=(\d+)$") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Output "Version=$($currentGPVersion)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { Write-Output $_ } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: }) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return (Set-GPTIniContents -Value $newGPTContent) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # gp_extensions.ps1 - newline is REQUIRED above | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Convert-GUIDListToHashTable($list) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $list = $list.Replace('[','').Replace(']','') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $output = @{} | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $list -split '}' | % { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $guid = $_.Trim().Replace('{','') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($guid -ne '') { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $output.Add($guid.ToLower(),'found') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Output $output | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Set-GPTExtensionGUIDs($guidList) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Generate the setting string | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $settingString = '[' + ( | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ($guidList.GetEnumerator() | ForEach-Object -Process { Write-Output "{$($_.Key.ToUpper())}" } | Sort-Object) -join '' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ) + ']' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($PolicyType.ToUpper() -eq 'USER') { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $settingName = 'gPCUserExtensionNames' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $settingName = 'gPCMachineExtensionNames' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Update the GPT.INI | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Updating $($settingName)=$($settingString)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $wasReplaced = $false | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $newGPTContent = (Get-GPTIniContents | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "$($settingName)=") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Output "$($settingName)=$($settingString)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $wasReplaced = $true | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { Write-Output $_ } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: }) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (-not $wasReplaced) { $newGPTContent += "$($settingName)=$($settingString)" } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (-not (Set-GPTIniContents -Value $newGPTContent)) { return $false } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Need to increment the version to take effect | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return Invoke-IncrementGPTVersion | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Get-GPExtensionListFromGPT { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptIniPath = "$($env:systemroot)\system32\GroupPolicy\gpt.ini" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $MachineExtensions = @{} | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $UserExtensions = @{} | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (Test-Path -Path $gptIniPath) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Get-Content $gptIniPath | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "gPCMachineExtensionNames=\[(.+)\]") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $MachineExtensions = (Convert-GUIDListToHashTable -List ([string]$matches[1].Trim())) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "gPCUserExtensionNames=(.+)$") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $UserExtensions = (Convert-GUIDListToHashTable -List ([string]$matches[1].Trim())) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Return @{ | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: 'Machine' = $MachineExtensions; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: 'User' = $UserExtensions | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # local_gpo_ext.ps1 - newline is REQUIRED above | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $PolicyType = 'Machine' # Machine or User | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $ExtensionList = '{D02B1F73-3407-48AE-BA88-E8213C6761F1}{35378EAC-683F-11D2-A89A-00C04FBBCFA2}' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: #Write-Host "PolicyType = $PolicyType" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: #Write-Host "ExtensionList = $ExtensionList" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # ext_command-set.ps1 - newline is REQUIRED above | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Setting the list of extension guids | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $isSet = $false | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($PolicyType -eq 'User') { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentList = (Get-GPExtensionListFromGPT).User | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentList = (Get-GPExtensionListFromGPT).Machine | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $shouldList = Convert-GUIDListToHashTable -List $ExtensionList | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Append missing elements from shouldList into currentLis | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $shouldList.GetEnumerator() | ForEach-Object -Process { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (-not $currentList.ContainsKey($_.Key)) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentList.Add($_.Key, $_.Value) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $isSet = Set-GPTExtensionGUIDs -GUIDList $currentList | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($isSet) { exit 0 } else { exit 1 } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: returned 1 instead of one of [0] | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Error: /Stage[main]/Windows_template::Local_group_policies/Windows_group_policy::Local::Machine_client_side_extensions[MachineGCE]/Exec[GPO-Local-UserCSE-MachineGCE]: Could not evaluate: Puppet::Util::Log requires a message | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Notice: /Stage[main]/Windows_template::Local_group_policies/Registry::Value[DebugPolicies]/Registry_value[HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\UserEnvDebugLevel]/ensure: created | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Error: param() | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # script-header.ps1 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $ErrorActionPreference = 'Stop' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $VerbosePreference = 'Continue' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Get-GPTIniContents { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptIniPath = "$($env:systemroot)\system32\GroupPolicy\gpt.ini" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Default if gpt.ini does not exist | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptContents = @('[General]','Version=0') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (Test-Path -Path $gptIniPath) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptContents = Get-Content $gptIniPath | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { Write-Verbose "$gptIniPath did not exist. Using default"} | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return $gptContents | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Set-GPTIniContents([string[]]$value) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptIniPath = "$($env:systemroot)\system32\GroupPolicy\gpt.ini" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Writing $gptIniPath" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $value | Out-File -FilePath $gptIniPath -Encoding ascii -Force -Confirm:$false | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return $true | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Invoke-IncrementGPTVersion { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Get the current gpt.ini version | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Get-GPTIniContents | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "Version=(\d+)$") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentGPVersion = [long]$matches[1] | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Current GP version is $currentGPVersion" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Incrementing $PolicyType version by one" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Ref: https://blogs.technet.microsoft.com/grouppolicy/2007/12/14/understanding-the-gpo-version-number/ | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Ref: https://technet.microsoft.com/en-us/library/cc978247.aspx | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # User policy is upper 16bits | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Machine policy is lower 16bits | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($PolicyType.ToUpper() -eq 'USER') { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentGPVersion += 0x00010000 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentGPVersion += 0x00000001 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "New GP version is $currentGPVersion" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Updating Version=$($currentGPVersion)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $newGPTContent = (Get-GPTIniContents | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "Version=(\d+)$") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Output "Version=$($currentGPVersion)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { Write-Output $_ } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: }) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return (Set-GPTIniContents -Value $newGPTContent) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # gp_extensions.ps1 - newline is REQUIRED above | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Convert-GUIDListToHashTable($list) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $list = $list.Replace('[','').Replace(']','') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $output = @{} | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $list -split '}' | % { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $guid = $_.Trim().Replace('{','') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($guid -ne '') { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $output.Add($guid.ToLower(),'found') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Output $output | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Set-GPTExtensionGUIDs($guidList) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Generate the setting string | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $settingString = '[' + ( | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ($guidList.GetEnumerator() | ForEach-Object -Process { Write-Output "{$($_.Key.ToUpper())}" } | Sort-Object) -join '' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ) + ']' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($PolicyType.ToUpper() -eq 'USER') { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $settingName = 'gPCUserExtensionNames' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $settingName = 'gPCMachineExtensionNames' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Update the GPT.INI | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Updating $($settingName)=$($settingString)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $wasReplaced = $false | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $newGPTContent = (Get-GPTIniContents | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "$($settingName)=") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Output "$($settingName)=$($settingString)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $wasReplaced = $true | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { Write-Output $_ } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: }) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (-not $wasReplaced) { $newGPTContent += "$($settingName)=$($settingString)" } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (-not (Set-GPTIniContents -Value $newGPTContent)) { return $false } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Need to increment the version to take effect | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return Invoke-IncrementGPTVersion | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Get-GPExtensionListFromGPT { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptIniPath = "$($env:systemroot)\system32\GroupPolicy\gpt.ini" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $MachineExtensions = @{} | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $UserExtensions = @{} | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (Test-Path -Path $gptIniPath) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Get-Content $gptIniPath | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "gPCMachineExtensionNames=\[(.+)\]") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $MachineExtensions = (Convert-GUIDListToHashTable -List ([string]$matches[1].Trim())) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "gPCUserExtensionNames=(.+)$") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $UserExtensions = (Convert-GUIDListToHashTable -List ([string]$matches[1].Trim())) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Return @{ | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: 'Machine' = $MachineExtensions; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: 'User' = $UserExtensions | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # local_gpo_ext.ps1 - newline is REQUIRED above | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $PolicyType = 'User' # Machine or User | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $ExtensionList = '{D02B1F73-3407-48AE-BA88-E8213C6761F1}{35378EAC-683F-11D2-A89A-00C04FBBCFA2}' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: #Write-Host "PolicyType = $PolicyType" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: #Write-Host "ExtensionList = $ExtensionList" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # ext_command-set.ps1 - newline is REQUIRED above | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Setting the list of extension guids | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $isSet = $false | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($PolicyType -eq 'User') { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentList = (Get-GPExtensionListFromGPT).User | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentList = (Get-GPExtensionListFromGPT).Machine | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $shouldList = Convert-GUIDListToHashTable -List $ExtensionList | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Append missing elements from shouldList into currentLis | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $shouldList.GetEnumerator() | ForEach-Object -Process { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (-not $currentList.ContainsKey($_.Key)) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentList.Add($_.Key, $_.Value) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $isSet = Set-GPTExtensionGUIDs -GUIDList $currentList | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($isSet) { exit 0 } else { exit 1 } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: returned 1 instead of one of [0] | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Error: /Stage[main]/Windows_template::Local_group_policies/Windows_group_policy::Local::User_client_side_extensions[UserGCE]/Exec[GPO-Local-UserCSE-UserGCE]: Could not evaluate: Puppet::Util::Log requires a message | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Error: param() | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # script-header.ps1 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $ErrorActionPreference = 'Stop' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $VerbosePreference = 'Continue' | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Get-GPTIniContents { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptIniPath = "$($env:systemroot)\system32\GroupPolicy\gpt.ini" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Default if gpt.ini does not exist | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptContents = @('[General]','Version=0') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (Test-Path -Path $gptIniPath) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptContents = Get-Content $gptIniPath | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { Write-Verbose "$gptIniPath did not exist. Using default"} | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return $gptContents | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Set-GPTIniContents([string[]]$value) { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $gptIniPath = "$($env:systemroot)\system32\GroupPolicy\gpt.ini" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Writing $gptIniPath" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $value | Out-File -FilePath $gptIniPath -Encoding ascii -Force -Confirm:$false | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return $true | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Function Invoke-IncrementGPTVersion { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Get the current gpt.ini version | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Get-GPTIniContents | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "Version=(\d+)$") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentGPVersion = [long]$matches[1] | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Current GP version is $currentGPVersion" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Incrementing $PolicyType version by one" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Ref: https://blogs.technet.microsoft.com/grouppolicy/2007/12/14/understanding-the-gpo-version-number/ | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Ref: https://technet.microsoft.com/en-us/library/cc978247.aspx | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # User policy is upper 16bits | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # Machine policy is lower 16bits | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($PolicyType.ToUpper() -eq 'USER') { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentGPVersion += 0x00010000 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $currentGPVersion += 0x00000001 | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "New GP version is $currentGPVersion" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Verbose "Updating Version=$($currentGPVersion)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $newGPTContent = (Get-GPTIniContents | | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ForEach-Object { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if ($_ -match "Version=(\d+)$") { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: Write-Output "Version=$($currentGPVersion)" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } else { Write-Output $_ } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: }) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return (Set-GPTIniContents -Value $newGPTContent) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: # PoLfileEditor.ps1 - newline is REQUIRED above | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: $PolFileEditorCS = @" | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: //FROM https://gallery.technet.microsoft.com/scriptcenter/Read-or-modify-Registrypol-778fed6e | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: namespace TJX.PolFileEditor | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: using System; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: using System.Collections.Generic; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: using System.Text; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: using System.IO; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: using Microsoft.Win32; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public enum PolEntryType : uint | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: REG_NONE = 0, | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: REG_SZ = 1, | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: REG_EXPAND_SZ = 2, | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: REG_BINARY = 3, | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: REG_DWORD = 4, | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: REG_DWORD_BIG_ENDIAN = 5, | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: REG_MULTI_SZ = 7, | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: REG_QWORD = 11, | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public class PolEntry : IComparable<PolEntry> | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: private List<byte> byteList; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public PolEntryType Type { get; set; } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public string KeyName { get; set; } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public string ValueName { get; set; } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: internal List<byte> DataBytes | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: get { return this.byteList; } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public uint DWORDValue | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: get | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: byte[] bytes = this.byteList.ToArray(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: switch (this.Type) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_NONE: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_MULTI_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_EXPAND_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: uint result; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (UInt32.TryParse(this.StringValue, out result)) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return result; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: else | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: throw new InvalidCastException(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_DWORD: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (bytes.Length != 4) { throw new InvalidOperationException(); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (BitConverter.IsLittleEndian == false) { Array.Reverse(bytes); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return BitConverter.ToUInt32(bytes, 0); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_DWORD_BIG_ENDIAN: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (bytes.Length != 4) { throw new InvalidOperationException(); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (BitConverter.IsLittleEndian == true) { Array.Reverse(bytes); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return BitConverter.ToUInt32(bytes, 0); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_QWORD: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (bytes.Length != 8) { throw new InvalidOperationException(); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (BitConverter.IsLittleEndian == false) { Array.Reverse(bytes); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ulong lvalue = BitConverter.ToUInt64(bytes, 0); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (lvalue > UInt32.MaxValue || lvalue < UInt32.MinValue) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: throw new OverflowException("QWORD value '" + lvalue.ToString() + "' cannot fit into an UInt32 value."); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return (uint)lvalue; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_BINARY: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (bytes.Length != 4) { throw new InvalidOperationException(); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return BitConverter.ToUInt32(bytes, 0); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: default: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: throw new Exception("Reached default cast that should be unreachable in PolEntry.UIntValue"); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: set | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.Type = PolEntryType.REG_DWORD; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.Clear(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: byte[] arrBytes = BitConverter.GetBytes(value); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (BitConverter.IsLittleEndian == false) { Array.Reverse(arrBytes); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.AddRange(arrBytes); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public ulong QWORDValue | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: get | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: byte[] bytes = this.byteList.ToArray(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: switch (this.Type) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_NONE: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_MULTI_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_EXPAND_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: ulong result; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (UInt64.TryParse(this.StringValue, out result)) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return result; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: else | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: throw new InvalidCastException(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_DWORD: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (bytes.Length != 4) { throw new InvalidOperationException(); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (BitConverter.IsLittleEndian == false) { Array.Reverse(bytes); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return (ulong)BitConverter.ToUInt32(bytes, 0); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_DWORD_BIG_ENDIAN: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (bytes.Length != 4) { throw new InvalidOperationException(); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (BitConverter.IsLittleEndian == true) { Array.Reverse(bytes); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return (ulong)BitConverter.ToUInt32(bytes, 0); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_QWORD: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (bytes.Length != 8) { throw new InvalidOperationException(); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (BitConverter.IsLittleEndian == false) { Array.Reverse(bytes); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return BitConverter.ToUInt64(bytes, 0); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_BINARY: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (bytes.Length != 8) { throw new InvalidOperationException(); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return BitConverter.ToUInt64(bytes, 0); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: default: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: throw new Exception("Reached default cast that should be unreachable in PolEntry.ULongValue"); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: set | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.Type = PolEntryType.REG_QWORD; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.Clear(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: byte[] arrBytes = BitConverter.GetBytes(value); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (BitConverter.IsLittleEndian == false) { Array.Reverse(arrBytes); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.AddRange(arrBytes); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public string StringValue | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: get | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: byte[] bytes = this.byteList.ToArray(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: StringBuilder sb = new StringBuilder(bytes.Length * 2); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: switch (this.Type) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_NONE: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return ""; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_MULTI_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: string[] mstring = MultiStringValue; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: for (int i = 0; i < mstring.Length; i++) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (i > 0) { sb.Append("\\0"); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: sb.Append(mstring[i]); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return sb.ToString(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_DWORD: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_DWORD_BIG_ENDIAN: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_QWORD: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return this.QWORDValue.ToString(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_BINARY: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: for (int i = 0; i < bytes.Length; i++) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: sb.AppendFormat("{0:X2}", bytes[i]); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return sb.ToString(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_EXPAND_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return UnicodeEncoding.Unicode.GetString(bytes).Trim('\0'); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: default: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: throw new Exception("Reached default cast that should be unreachable in PolEntry.StringValue"); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: set | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (value == null) { value = String.Empty; } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.Type = PolEntryType.REG_SZ; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.Clear(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.AddRange(UnicodeEncoding.Unicode.GetBytes(value + "\0")); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public string[] MultiStringValue | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: get | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: byte[] bytes = this.byteList.ToArray(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: switch (this.Type) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_NONE: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: throw new InvalidCastException("StringValue cannot be used on the REG_NONE type."); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_DWORD: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_DWORD_BIG_ENDIAN: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_QWORD: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_BINARY: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_EXPAND_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return new string[] { this.StringValue }; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: case PolEntryType.REG_MULTI_SZ: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: List<string> list = new List<string>(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: StringBuilder sb = new StringBuilder(256); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: for (int i = 0; i < (bytes.Length - 1); i += 2) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: char[] curChar = UnicodeEncoding.Unicode.GetChars(bytes, i, 2); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (curChar[0] == '\0') | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (sb.Length == 0) { break; } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: list.Add(sb.ToString()); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: sb.Length = 0; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: else | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: sb.Append(curChar[0]); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: return list.ToArray(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: default: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: throw new Exception("Reached default cast that should be unreachable in PolEntry.MultiStringValue"); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: set | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.Type = PolEntryType.REG_MULTI_SZ; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.Clear(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (value != null) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: for (int i = 0; i < value.Length; i++) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (i > 0) { this.byteList.AddRange(UnicodeEncoding.Unicode.GetBytes("\0")); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (value[i] != null) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.AddRange(UnicodeEncoding.Unicode.GetBytes(value[i])); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.AddRange(UnicodeEncoding.Unicode.GetBytes("\0\0")); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: public byte[] BinaryValue | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: get { return this.byteList.ToArray(); } | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: set | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.Type = PolEntryType.REG_BINARY; | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.Clear(); | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: if (value != null) | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: { | |
windows-2016rtm-x86_64-vmware-vsphere-cygwin: this.byteList.AddRange(value); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment