3gstudent/Homework-of-Powershell

未能找到路径gpreport.xml/Backup.xml

FuckAllWorld opened this issue · 2 comments

系统:Windows2008 R2
未能找到路径gpreport.xml/Backup.xml

Set-Content : 未能找到路径“C:\Users\Administrator\Desktop\yes{2CB4AF05-DBB3-4313-B82C-F477B435ED9D}\gpreport.xml”的
一部分。
所在位置 C:\Users\Administrator\Desktop\yes\New-GPOImmediateTask.ps1:206 字符: 28

  • $Content2 | Set-Content <<<<  -Encoding Unicode -Path $GpreportPath
    
    • CategoryInfo : ObjectNotFound: (C:\Users\Admini...D}\gpreport.xml:String) [Set-Content], DirectoryNotFo
      undException
    • FullyQualifiedErrorId : GetContentWriterDirectoryNotFoundError,Microsoft.PowerShell.Commands.SetContentCommand

Import-GPO : 数据无效。 (异常来自 HRESULT:0x8007000D)
所在位置 C:\Users\Administrator\Desktop\yes\New-GPOImmediateTask.ps1:220 字符: 15

  • Import-GPO <<<<  -BackupId $BackupId -TargetName $GPODisplayName -Path (Resolve-Path './').Path | Out-Null
    
    • CategoryInfo : NotSpecified: (:) [Import-GPO], COMException
    • FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.GroupPolicy.Commands.ImportGpoComm
      and

https://github.com/3gstudent/Homework-of-Powershell/blob/master/New-GPOImmediateTask.ps1#L82

先看一下你备份gpo的时候是否正常,是否获得文件Backup.xml

https://github.com/3gstudent/Homework-of-Powershell/blob/master/New-GPOImmediateTask.ps1#L82

先看一下你备份gpo的时候是否正常,是否获得文件Backup.xml

PS C:\Users\Administrator\Desktop\yes> New-GPOImmediateTask -TaskName Debugging -GPODisplayName test -SysPath '\testlab
.local\sysvol\testlab.local' -CommandArguments '-c "123 | Out-File C:\debug.txt"'

但是backup.xml等会生成在C:\Users\Administrator目录下,schtasks.xml会生成在C:\Users\Administrator\Desktop\yes目录下,导致脚本无法正常运行。应该是和./有关系