PSWA 5.0 upgrade causes Set-Location to no longer work in startup script

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Edmond Yee Edmond Yee 9 months ago.

  • Author
    Posts
  • #36002
    Profile photo of Edmond Yee
    Edmond Yee
    Participant

    I had previously setup PSWA 4.0 that executed a profile.ps1 script at logon to resize the console, add snapins, and drop the user into a UNC network location where the scripts are contained. I upgraded to PS 5.0 on Friday and now when users login, all elements of the script work EXCEPT Set-Location. I have tried to cd to a local path instead of UNC, which also did not work. There are no errors or warnings. If I execute the startup script after I am already logged in to the PSWA, it executes properly and changes to the UNC path. Has anyone else noticed this?

  • #36010
    Profile photo of tommymaynard
    tommymaynard
    Member

    I've yet to put PowerShell 5.0 on a PSWA server. That said, in a situation such as this, I'd check the event logs. Check the Windows PowerShell log, as well as Microsoft-Windows-PowerShell and especially Microsoft-Windows-PowerShellWebAccess. I assume that when you say "a profile.ps1 script," that you're referring to a StartUpScript .ps1 file. I'd be tempted to add a line (below) to the top of the StartUpScript file that searched for the Set-Location command. Maybe even add it in between each of the other things your .ps1 file is successfully completing.

    "Set-Location Command: $([bool](Get-Command -Name Set-Location))"

  • #36097
    Profile photo of Edmond Yee
    Edmond Yee
    Participant

    Thanks for your reply Tommy. First let me say that you actually helped me setup my PSWA (indirectly) after I stumbled upon your other solution for https://powershell.org/forums/topic/powershell-web-access-vs-ad-cmdlet/. I actually ended up just making a separate PS Config for each user on my PSWA (about 5 users) and then set each one with -RunAsCredential, and they are now able to run both AD and Quest AD cmdlets in PSWA without error.

    When I added the "Set-Location Command: $([bool](Get-Command -Name Set-Location))" command to the startupscript, I can no longer sign in and it errors out. I modified it and just simply added "Get-Command Set-Location" the startup, and I receive no output, as if it doesn't exist at startup. However, once the startup finishes and I type the command manually, it shows as expected.

    It is pretty strange, and it almost seems like the command is simply not there at logon, but is there after logon. I have looked through the logs and was unable to find anything obvious (there were no errors, and few warnings) Do you have any other thoughts? I am also wondering if a workaround like adding set-location or cd to the pssc file.

  • #36171
    Profile photo of Edmond Yee
    Edmond Yee
    Participant

    Just as an update, I tried to completely uninstall PSWA and reinstall in case something was added to the install feature in Posh 5.0, no luck. I also tried to add "Import-Module Microsoft.PowerShell.Management" since set-location is a part of that module in case it was loading that immediately during startup and still no luck.

    I even went as far as putting the set-location command into another script and then calling that script at the end of my startup script, also with no luck.

You must be logged in to reply to this topic.