我有一台机器,我需要从网络共享(在域上)复制文件,以便从域外的机器进行部署.
目前我有以下代码;
Configuration deployWebsite { param ( [string[]] $MachineName = "localhost" ) Node $MachineName { File Test { SourcePath = "\\buildserver\mywebsite" DestinationPath = "C:\deployments" Recurse = $true Type = "Directory" } } } deployWebsite -MachineName "at-test-2012"
我得到的错误如下;
PS C:\dsc> Start-DscConfiguration -Path .\deployWebsite -CimSession $sess -Wait -Verbose -Force VERBOSE: Perform operation 'Invoke CimMethod' with following parameters,''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsof t/Windows/DesiredStateConfiguration'. VERBOSE: An LCM method call arrived from computer AT-TEST-2012 with user sid S-1-5-21-77344112-180879520-4075690869-1002. VERBOSE: [AT-TEST-2012]: LCM: [ Start Set ] VERBOSE: [AT-TEST-2012]: LCM: [ Start Resource ] [[File]Test] VERBOSE: [AT-TEST-2012]: LCM: [ Start Test ] [[File]Test] VERBOSE: [AT-TEST-2012]: [[File]Test] Access is denied. VERBOSE: [AT-TEST-2012]: [[File]Test] The related file/directory is: \\buildserver\mywebsite. VERBOSE: [AT-TEST-2012]: [[File]Test] The path cannot point to the root directory or to the root of a net share. VERBOSE: [AT-TEST-2012]: [[File]Test] The related file/directory is: \\buildserver\mywebsite. VERBOSE: [AT-TEST-2012]: [[File]Test] SourcePath must be specified if you want to configure the destination directory recursively. Make sure that SourcePath is a di rectory and that it is accessible. SourcePath must be specified if you want to configure the destination directory recursively. Make sure that SourcePath is a directory and that it is accessible. + CategoryInfo : InvalidArgument: (:) [],CimException + FullyQualifiedErrorId : MI RESULT 4 + PSComputerName : at-test-2012 The SendConfigurationApply function did not succeed. + CategoryInfo : InvalidArgument: (root/Microsoft/...gurationManager:String) [],CimException + FullyQualifiedErrorId : MI RESULT 4 + PSComputerName : at-test-2012 VERBOSE: Operation 'Invoke CimMethod' complete. VERBOSE: Time taken for configuration job to complete is 3.979 seconds
CIM会议似乎设置得很好.
PS C:\dsc> Get-CimSession Id : 1 Name : CimSession1 InstanceId : 7ae9cd9b-fc65-4879-94c1-ec9805479500 ComputerName : at-test-2012 Protocol : WSMAN
它是使用以下代码创建的;
$sess = New-CIMSession -cn at-test-2012 -Authentication Credssp -Credential $cred
它是通过工作组计算机上的本地管理员的用户传递的凭据,并且是尝试从中提取文件的域计算机上的本地用户.
如果我通过创建PSSession尝试另一个测试,并尝试复制文件然后它工作正常,我看到文件出现在工作组计算机上.
$cred = Get-Credential -Credential deployuser $sess = New-PSSession -cn at-test-2012 -Authentication Credssp -Credential $cred Invoke-Command -Session $sess -ScriptBlock {Copy-Item -Path '\\buildserver\mywebsite' -Destination 'C:\deployments'}
问题是Start-DscConfiguration似乎不支持PSSessions,只支持CIMSessions.
那么,关于下一步尝试的任何指示?我认为我的CIMsession设置正确,我认为我在文件共享,工作组机器上的所有必要设置都正确设置,因为PSSession工作正常.
干杯,
安迪
解决方法
通常我会通过以下三种方式之一处理这样的问题:
>使用显式创建远程计算机上的计划任务
凭证,在本地执行Start-DscConfiguration.它会运行
完全与本地用户一样,用于远程处理的下一跳.
>考虑创建和使用JEA端点.这更多
复杂,但让你走向简化的道路
正在进行的管理远程机器的凭证管理.
>您可以使用创建远程共享的映射驱动器
使用类似脚本资源的显式信用
如果您有其他可能影响网络变化的配置,请注意进行远程Start-DscConfiguration.
例如,通过JustEnoughAdministration资源创建前面提到的JEA端点可以重置WinRM并过早地中断本地和远程Start-DscConfiguration调用-Wait.
计划任务不受影响配置中的网络影响,以及来自其他环境因素的简单网络剥落.最重要的是,如果您需要监控配置的稳定性,这是读者的练习(或未来的问题/答案).