0

Completely baffled by this. Can't seem to run any ps1 files on powershell?? I know for sure it was working fine last week.

Here is the error I'm getting. It suggests the file doesn't exist, so I proved it does by using Test-Path first...

PS C:\WINDOWS\system32> cd C:\Users\Public
if (Test-Path test.ps1) {
    ./test.ps1
}
./test.ps1 : The term './test.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:3 char:5
+     ./test.ps1
+     ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (./test.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Any suggestions of what I could try?

Doesn't seem to be related to permissions. I was originally running from a network drive, but same result from C drive. Restarted the PC 2 times already. I'm not aware of any changes made to my PC in the last week that could have caused this?

EDIT As requested:

PS C:\Users\Public> dir .\test.ps1


    Directory C:\Users\Public


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       01/11/2019     14:35            208 test.ps1
  • 2
    Have you tried changing hte forward slash to a back-slash? .\test.ps1 – Keith Miller Mar 26 at 16:45
  • @Keith Yes, tried both ways. Tried with double quotes, single quotes, full path, etc. – Skytunnel Mar 26 at 16:48
  • 1
    test.ps1 is in the Users/Public folder? Make dir .\test.ps1 – Yisroel Tech Mar 26 at 17:03
  • @YisroelTech result of dir added to question. Thanks – Skytunnel Mar 26 at 17:19
  • Try gc ./test.ps1 – Walter Mitty Mar 26 at 17:49
2

This is not a satisfactory answer as to why the following caused it; but scripts are now working again. So here's what happened...

I've been working remotely from home the last 2 weeks using CAG (Critix Access Gateway).

I went back in the office today for the first time, and when I connected directly to the network, all my scripts where working again as normal.

It turns out IT have been releasing an alternative to CAG use called CheckPointVPN. My user group was updated to support it earlier in the week (which may have been when my scripts stopped working?).

I got it fully installed while in the office, and now I'm back working remotely from home again, and all scripts are working well.

As I said, this isn't exactly a clear answer. But maybe it'll help someone else who might be experenicing something similar

  • 1
    It's more of an answer then you realize. The error you received basically indicated the script could not find the file. – Ramhound 2 days ago
  • @Ramhound what's that got to do with working remotely though? Especialy when you consider that I tested it from the C Drive? – Skytunnel 2 days ago
  • You indicated that it was solved once you had a working secure connection to your work's network. The script not being found is literally the only explanation for the error, if you made no other changes to the script, between when it wasn't working and it was working. The file that could not be found, likely is within the script you called, not the script you were running directly. – Ramhound 2 days ago

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.