jeremy-jameson / SDN

This repo includes PowerShell scripts and VMM service templates for setting up the Microsoft Software Defined Networking (SDN) Stack using Windows Server 2016
Other
0 stars 0 forks source link

Error running SDNExpress.ps1 - "Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied." (line 3604) #4

Open jeremy-jameson opened 6 years ago

jeremy-jameson commented 6 years ago

Command line: .\SDNExpress.ps1 -ConfigurationDataFile .\FabricConfig.TECHTOOLBOX.psd1 -Verbose

Output

...
VERBOSE: [TT-HV05A]:                            [[Script]InstallHostCert] Performing the operation "Set-TargetResource" on target "Executing the SetScript with the user supplied credential".
VERBOSE: [TT-HV05A]: LCM:  [ End    Set      ]  [[Script]InstallHostCert]  in 1.7190 seconds.
PowerShell DSC resource MSFT_ScriptResource  failed to execute Set-TargetResource functionality with error message: Access to the registry key
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.
At D:\NotBackedUp\SDN\SDNExpress\scripts\SDNExpress.ps1:3604 char:13
+             Start-DscConfiguration -Path .\ConfigureHostNetworkingPre ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : TT-HV05A
jeremy-jameson commented 6 years ago

The error occurs when the account specified by the HostUsername variable in the configuration file does not have administrator permission on the Hyper-V host servers.

To resolve the error, add the HostUsername account to the Administrators group on each Hyper-V server:

$hyperVHosts = @("TT-HV05A", "TT-HV05B", "TT-HV05C")
$domain = "TECHTOOLBOX"
$username = "s-nc01-host"

$script = "
([ADSI]'WinNT://./Administrators,group').Add(
    'WinNT://$domain/$username,user')
"

$scriptBlock = [ScriptBlock]::Create($script)

$hyperVHosts |
    foreach {
        $computer = $_

        Invoke-Command -ComputerName $computer -ScriptBlock $scriptBlock
    }