$folder = "$env:HOMEDRIVE\TestFolder"
New-Item -ItemType directory -Path $folder
  • note that the same group policy error occurs when $folder is set to "C:\..."

Execution policy is unrestricted, and the script runs fine when ran manually in Windows 8.1 (folder is created). I created a group policy (Computer Configuration > Windows Settings > Scripts > Startup) Added TestFolder.ps1 to \domain.com\SysVol\domain.com\Policies...\Machine\Scripts\Startup. Security Filtering configured to apply to the Domain Computers group. Policy applies fine to computer.

I get the following error when the policy attempts to apply script:

Group Policy event 1130

Startup script failed. 
    GPO Name : TestFolder Script
    GPO File System Path : \\domain.com\SysVol\domain.com\Policies\...\Machine
    Script Name: TestFolder.ps1

SupportInfo1 178254400 
  SupportInfo2 71 
  ErrorCode 267 
  ErrorDescription The directory name is invalid.  
  ScriptType 0 
  GPODisplayName TestFolder Script
  GPOFileSystemPath \\domain.com\SysVol\domain.com\Policies\...\Machine 
  GPOScriptCommandString TestFolder.ps1

I can't help but notice that \Scripts\Startup is omitted from the File System Path in the error information... Ideas?

EDIT: The group policy applies to a Windows 7 VM fine. Seems to me a problem with Windows 8.1.

  • 2
    Does HOMEDRIVE exist at machine startup, before the user logs on? I'm not sure it does, but I don't have a Windows PC handy to check... – DarkMoon Aug 2 '14 at 7:47
  • I have actually noticed that there does seem to be a difference (I'm guessing with permissions) on directories in the C:\ - C:|windows\system with Windows 7 and Windows 8. I have long suspected there is some sort of added "security" in those directories that makes it harder. – Get-HomeByFiveOClock Sep 6 '14 at 4:55

I don't have any authoritative references, but the $HOME, $env:HOMEDRIVE and $env:HOMEPATH variables are user-specific environment variables.

It's unlikely that they would get assigned when you start a PowerShell host in the security context of the machine and not the user

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.