Script Converted to Exe doesn't Find Hidden Folders on c:\Windows

Hi Guys,

I’m writing a script to Reconfigure the Group Policies on a Couple of Computers in my Company
To do this I Delete the Old Ones and Update the new ones.
This works fine in the Script but once I Convert it to an Exe it stops working…
the Exe also works fine when I use my test Folder, but the windows folder doesn’t seem to work

This Doesn’t Work:

$a = Get-ChildItem $env:windir\System32\* -Hidden -filter "*GroupPolicy*"
Write-Host $a
if (!$null -eq $a)
{
    Write-host "Found Something, Deleting"
} else 
{
    Write-host "Found Nothing"
}
Start-Sleep -Seconds 5

This Works

$a = Get-ChildItem c:\temp\* -Hidden -filter "*GroupPolicy*"
Write-Host $a
if (!$null -eq $a)
{
    Write-host "Found Something, Deleting"
} else
{
    Write-host "Found Nothing"
}
Start-Sleep -Seconds 10

Any Help would be Apreciated
Thx

This might have to do with the architecture of the exe. I wonder if system32 is being redirected. Try setting the platform property to ‘x64’.

https://docs.poshtools.com/powershell-pro-tools-documentation/packaging/package.psd1#config-file-schema

2 Likes

That works Perfectly thx :slight_smile:

1 Like

I had the same issue with reading the Registry.
When I havn’t set the platform property to x64 the needed Values where not availableon my Script too.

Thats an good Point to know that sometimes the x64 needs to be set on the packages.psd1