Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts

    Read/Write to the C:\Windows\System32\WindowsPowerShell\v1.0 folder

    As I am trying out PowerShell, I have to make changes to the profile.ps1 script and then copy it into the folder because I am denied access. But since I can copy / overwrite files there anyway, doesn't that defeat the purpose of rights? Anyhow, is there a way I can set my rights to that folder to read and write? I tried it through the Security tab for the folder but could not get it to work.

    Chuck Billow
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  2. #2
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,572
    Thanks
    5
    Thanked 1,057 Times in 926 Posts
    Why are you messing with that folder? Why aren't you using the %profile path?

    See Create PowerShell Profile File and Customizing your PowerShell Profile.
    Joe

  3. #3
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    Joe, if I want to have all access from any user on my machine, I need profile.ps1 in %windir%\system32\WindowsPowerShell\v1.0\profile.p s1 don't I?

    https://technet.microsoft.com/en-us/...(v=vs.85).aspx

    Chuck
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Chuck,

    Create a One line profile in: %windir%\system32\WindowsPowerShell\v1.0\profile.p s1

    C:\Users\Public\WindowsPowerShell\PSProfile.ps1"

    Now make all your profile changes to the PSProfile.ps1 file in the public directory...problem solved.

    BTW: Don't forget to create the WindowsPowerShell directory in the public folder.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  5. #5
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,572
    Thanks
    5
    Thanked 1,057 Times in 926 Posts
    It does not defeat the purpose of rights. If it did you could directly save into the folder. With Win10 I've had mixed results (at best) changing security permissions on system folders. You have to be very careful you don't mess with the system's ability to do what it needs to do with the folder.

    Did you take ownership of the folder before attempting to change the permissions?
    Joe

  6. #6
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    No, I didn't take ownership. I did it as an Admin though. I'm not thrilled with changing system folders Joe. But I am liking the idea of a uniform basic setup regardless of who is logged in. While this could be accomplished by replicating the profile.ps1, it would seem a lot more prudent to do it in one file...so...?

    I don't know why Microsoft stuck that script there, but they did.
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  7. #7
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    RG, that sounds like a great idea! Why the single quote?

    Edit:

    Except when I ran it that way I got the following:

    C:\Users\Public\WindowsPowerShell\PSProfile.ps1 : The term 'C:\Users\Public\WindowsPowerShell\PSProfile.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 C:\Windows\System32\WindowsPowerShell\v1.0\profile .ps1:1 char:1
    + C:\Users\Public\WindowsPowerShell\PSProfile.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (C:\Users\Public...l\PSProfile.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException



    Thanks,
    Chuck
    Last edited by CWBillow; 2016-07-01 at 20:39.
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  8. #8
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    So, if it seems to read C:\Windows\System32\WindowsPowerShell\v1.0\profile .ps1 and then read C:\Users\Public\WindowsPowerShell\profile.ps1.

    The first has nothing but C:\Users\Public\WindowsPowerShell\PSProfile.ps1 in it, and the second is as follows:

    $console = $host.UI.RawUI
    $a = (Get-Host).UI.RawUI

    function prompt {"PS: $(get-date)>"}
    Set-Location C:\Users\CWBillow\Documents\WindowsPowerShellScrip ts

    $colors = $host.PrivateData
    $colors.VerboseForegroundColor = "white"
    $colors.VerboseBackgroundColor = "blue"
    $colors.WarningForegroundColor = "red"
    $colors.WarningBackgroundColor = "white"
    $colors.ErrorForegroundColor = "white"
    $colors.ErrorBackgroundColor = "red"

    # $a.ErrorBackgroundColor = "red"
    # $a.ErrorForegroundColor = "white"
    #
    # $a.WarningForegroundColor = "red"
    # $a.WarningBackgroundColor = "white"
    #
    # $a.WarningBackgroundColor = "red"
    # $a.WarningForegroundColor = "white"
    #
    # Welcome message

    cls

    function move-the-cursor([int]$x, [int] $y)
    {
    $Host.UI.RawUI.CursorPosition = New-Object System.Management.Automation.Host.Coordinates $x , $y
    $Host.UI.Write('Hello...')
    }

    move-the-cursor 1 1
    # echo "Tested by CB : OK"
    "You are now entering PowerShell again, " + $env:Username

    # Set-Location -Path C:\ -PassThru

    CD C:\

    $a.WindowTitle = "PowerShell Script Center"

    "All" I want it to do is set the colors, which it does, clear the screen and then move to C:\.

    It is this last element I cannot seem to get.

    What am I doing wrong here?

    Chuck Billow
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  9. #9
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,572
    Thanks
    5
    Thanked 1,057 Times in 926 Posts
    Why CD instead of Set-Location?

    Have you tried removing eveything else and try either one by itself?
    Is it the directory change or the title that fails?
    Joe

  10. #10
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    It's the directory change, Joe. When the script ends, it is in

    C:\Users\CWBillow\Documents\WindowsPowerShellScrip ts

    Instead of C:\

    Edit:

    So I changed it to

    Set-Location C:\

    But it made no change.
    Last edited by CWBillow; 2016-07-01 at 22:19.
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  11. #11
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,572
    Thanks
    5
    Thanked 1,057 Times in 926 Posts
    What permissions does the user account have for C:?
    Joe

  12. #12
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    As one of the Administrators, it/he/I has/have all but Special Permissions.

    Chuck
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  13. #13
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Chuck,

    This works in my Profile:
    Code:
    g:
    cd \bekdocs\scripts
    I also tried this:
    Code:
    Set-Location -LiteralPath 'G:\BEKDocs\Scripts'
    and it also worked.

    HTH
    Last edited by RetiredGeek; 2016-07-02 at 10:17.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  14. #14
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    RG, I have some gnome somewhere that must be laughing right now. NEITHER worked. And I get NO errors or warnings.

    After pointing to the public folder via the pointer you had suggested ( C:\Users\Public\WindowsPowerShell\PSProfile.ps1" ) I placed the profile.ps1 in
    C:\Users\Public\WindowsPowerShell. There are, that I have found, no other scripts. The profile.ps1 reads

    $console = $host.UI.RawUI
    $a = (Get-Host).UI.RawUI

    function prompt {"PS: $(get-date)>"}
    Set-Location C:\Users\CWBillow\Documents\WindowsPowerShellScrip ts

    $colors = $host.PrivateData
    $colors.VerboseForegroundColor = "white"
    $colors.VerboseBackgroundColor = "blue"
    $colors.WarningForegroundColor = "red"
    $colors.WarningBackgroundColor = "white"
    $colors.ErrorForegroundColor = "white"
    $colors.ErrorBackgroundColor = "red"

    # $a.ErrorBackgroundColor = "red"
    # $a.ErrorForegroundColor = "white"
    #
    # $a.WarningForegroundColor = "red"
    # $a.WarningBackgroundColor = "white"
    #
    # $a.WarningBackgroundColor = "red"
    # $a.WarningForegroundColor = "white"
    #
    # Welcome message

    cls

    function move-the-cursor([int]$x, [int] $y)
    {
    $Host.UI.RawUI.CursorPosition = New-Object System.Management.Automation.Host.Coordinates $x , $y
    $Host.UI.Write('Hello...')
    }

    move-the-cursor 1 1
    # echo "Tested by CB : OK"
    "You are now entering PowerShell again, " + $env:Username

    # Set-Location -Path C:\ -PassThru

    # Set-Location -Path C:\

    C:
    CD \


    $a.WindowTitle = "PowerShell Script Center"

    But when finished, the location is C:\Users\CWBillow\Documents\WindowsPowerShellScrip ts

    The Set-Location -Path C:\ is held back because I had already tried it and was then trying the "direct approach."

    I haven't had this much runaround since I was learning batch files in the 80's!
    Last edited by CWBillow; 2016-07-02 at 13:24.
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  15. #15
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Chuck,

    Try this Profile.ps1 file as a test.

    Code:
    Read-Host -Prompt "You are now in the Public Profile`nPress any key to continue:"
    
    $console = $host.UI.RawUI
    $a = (Get-Host).UI.RawUI
    
    function prompt {"PS: $(get-date)>"}
    Set-Location -LiteralPath 'C:\Users\CWBillow\Documents\WindowsPowerShellScripts'
    
    Get-ChildItem   #Should list the directory above
    Read-Host "Press any key to continue..."
    
    $colors = $host.PrivateData
    $colors.VerboseForegroundColor = "white"
    $colors.VerboseBackgroundColor = "blue"
    $colors.WarningForegroundColor = "red"
    $colors.WarningBackgroundColor = "white"
    $colors.ErrorForegroundColor = "white"
    $colors.ErrorBackgroundColor = "red"
    
    Clear-Host
    
    function move-the-cursor([int]$x, [int] $y)
    {
    $Host.UI.RawUI.CursorPosition = New-Object System.Management.Automation.Host.Coordinates $x , $y
    $Host.UI.Write('Hello...')
    }
    
    move-the-cursor 1 1
    # echo "Tested by CB : OK"
    "You are now entering PowerShell again, " + $env:Username
    
    Set-Location -LiteralPath 'C:\'
    
    $a.WindowTitle = "PowerShell Script Center"
    
    Get-ChildItem   #This should list your C:\ directory
    It seems to work just fine for me (of course the change to your user directory fails but the error message is in White on Red!)

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  16. The Following User Says Thank You to RetiredGeek For This Useful Post:

    CWBillow (2016-07-06)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •