The script works in ISE but not when running from the command line (using administrator).
I might be off base with this (and maybe thinking a little too far "out of the box"), but I'm curious about the above statement.
Specifically, what do you mean by "using administrator"? Are you using the same domain account to run Powershell_ISE.exe and Powershell.exe? Are both processes being run with or without UAC elevation? IE "run as administrator"? Are you running both processes interactively? (That is; not using task scheduler.)
If you launch a new instance of Powershell_ISE.exe and execute the .ps1 file from the PS prompt, does it work or fail? Don't load the script into the editor, just run the .ps1 from the prompt.
Or from the ISE prompt run a sub instance of Powershell.exe and have it run the script. Like I did with get-host.
PS C:\WINDOWS\system32> (Get-Host).Name
Windows PowerShell ISE Host
PS C:\WINDOWS\system32> powershell.exe "(Get-Host).Name"
ConsoleHost
PS C:\WINDOWS\system32>