[20]Window PowerShell DSC学习系列---- start-dscconfiguration 中遇到 Access Denied的解决方案

来源:互联网 发布:淘宝外卖超出配送范围 编辑:程序博客网 时间:2024/06/07 15:22

当我们执行start-DscConfiguration -computername psdsc-window201 -Path c:\DSC\TestFile -Wait -Verbose -force

这条命令的时候,会遇到下面的问题


问题的根源有很多,解决的也不相同办法,主要有以下解决方法:

@执行下面的命令从而确保该开启的服务都已经开启Enable-PSRemoting

其输出的界面信息如下:
PS C:\windows\system32> Enable-PSRemoting
WinRM Quick Configuration
Running command "Set-WSManQuickConfig" to enable remote management of this computer by using the Windows Remote
Management (WinRM) service.
This includes:
1. Starting or restarting (if already started) the WinRM service
2. Setting the WinRM service startup type to Automatic
3. Creating a listener to accept requests on any IP address
4. Enabling Windows Firewall inbound rule exceptions for WS-Management traffic (for http only).
Do you want to continue?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y
WinRM is already set up to receive requests on this computer.
WinRM is already set up for remote management on this computer.
Confirm
Are you sure you want to perform this action?
Performing the operation "Set-PSSessionConfiguration" on target "Name: microsoft.powershell SDDL:
O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This lets selected users remotely run Windows
PowerShell commands on this computer.".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y
Confirm
Are you sure you want to perform this action?
Performing the operation "Set-PSSessionConfiguration" on target "Name: microsoft.powershell.workflow SDDL:
O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This lets selected users remotely run Windows
PowerShell commands on this computer.".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y
Confirm
Are you sure you want to perform this action?
Performing the operation "Set-PSSessionConfiguration" on target "Name: microsoft.powershell32 SDDL:
O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This lets selected users remotely run Windows
PowerShell commands on this computer.".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y
Confirm
Are you sure you want to perform this action?
Performing the operation "Set-PSSessionConfiguration" on target "Name: microsoft.windows.servermanagerworkflows SDDL:
O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This lets selected users remotely run Windows
PowerShell commands on this computer.".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y

@ help about_Remote_Troubleshooting 查看更多的帮助信息

通过help about_Remote_Troubleshooting 查看更多的帮助信息

@运行Set-WSManQuickConfig -SkipNetworkProfileCheck

When you connect your network, it gets set to Public, Private, or Domain. If the current profile is set to Public, Set-WSManQuickConfig will fail with that message. You can either change it (if the system will let you) or skip the profile check.
就执行下面的命令:

Set-WSManQuickConfig -SkipNetworkProfileCheck


@其他原因

另外,也可能是Winrm的设置没有设置好,比如,监听的5985端口的服务没有开启,认证的方式没有设置正确;可以通过下面的方式进行查看。
winrm get winrm/config
那么如何设置其值呢?有很多的方法,下面介绍两种方法:在CMD窗口中和在PowerShell窗口中
#1 需要在cmd窗口,而不是PowerShell窗口
winrm set winrm/config/client @{TrustedHosts="*"}

#2 在PowerShell窗口中,需要加上单引号
winrm set winrm/config/client ‘@{TrustedHosts=”*”}’
winrm set winrm/config/service ‘@{EnableCompatibilityHttpListener="true"}'




1 0
原创粉丝点击