Powershell DSC文件复制 – 工作组机器
我有一台机器,我需要从网络共享(在域上)复制文件,以便从域外的机器进行部署.
目前我有以下代码; Configuration deployWebsite { param ( [string[]] $MachineName = "localhost" ) Node $MachineName { File Test { SourcePath = "buildservermywebsite" DestinationPath = "C:deployments" Recurse = $true Type = "Directory" } } } deployWebsite -MachineName "at-test-2012" 我运行这个,我能够生成一个很好的MOF文件. 我得到的错误如下; 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: buildservermywebsite. 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: buildservermywebsite. 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 'buildservermywebsite' -Destination 'C:deployments'} 问题是Start-DscConfiguration似乎不支持PSSessions,只支持CIMSessions. 那么,关于下一步尝试的任何指示?我认为我的CIMsession设置正确,我认为我在文件共享,工作组机器上的所有必要设置都正确设置,因为PSSession工作正常. 干杯, 解决方法
通常我会通过以下三种方式之一处理这样的问题:
>使用显式创建远程计算机上的计划任务 如果您有其他可能影响网络变化的配置,请注意进行远程Start-DscConfiguration. 计划任务不受影响配置中的网络影响,以及来自其他环境因素的简单网络剥落.最重要的是,如果您需要监控配置的稳定性,这是读者的练习(或未来的问题/答案). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |