PowerShell Scripting - The Basics  

Page 4 of 4 FirstFirst ... 234

  1. Posts : 56,832
    Multi-boot Windows 10/11 - RTM, RP, Beta, and Insider
       #30

    I will not let my simple request turn into a senseless argument. I am done. Do as you please.
      My Computers


  2. Posts : 17,661
    Windows 10 Pro
    Thread Starter
       #31

    Matthew Wai said:
    Call PowerShell -ExecutionPolicy ByPass -file "D:\Folder_name\File_name.ps1"
    f14tomcat said:
    To all members, no one in particular..... please refrain from posting in all bold bright colors, like all bold red. It is not as easy to read, particularly if more than one sentence. Also, may not render well or at all in certain TF themes. I believe John has mentioned this in the past. Thanks.
    Matthew Wai said:
    I used red and boldface because it was a line of commands. I always do so when posting commands.
    I fully agree with @Dick. Nothing personal, Matthew, in my books you are a good geek, an asset to our forums. Just expressing my sincere, personal opinion.

    Using various colours and fonts is something I do not understand. In my opinion, the best option is just use bold font in [C] or [CODE] tags.

    C tags:

    Call PowerShell -ExecutionPolicy ByPass -file "D:\Folder_name\File_name.ps1"

    CODE tags:

    Code:
    Call PowerShell -ExecutionPolicy ByPass -file "D:\Folder_name\File_name.ps1"


    In fact, I have a rule which I have followed all my years here on these forums: I will absolutely not reply to any OPs, who post their request for help in any other font and colour than the forum default. I hate to read these posts, and want nothing to do with an OP who feels that he / she needs some cosmetics to make the post understood.

    Kari
      My Computer


  3. Posts : 15
    Windows 10 Pro Build 19042
       #32

    Thank you, that worked great. Do you know of a tutorial I can go to to learn how I could make this short little program, for example, run for a user by just clicking an icon?
      My Computer


  4. Posts : 7,607
    Windows 10 Home 20H2
       #33

    Create a shortcut with the following target:

    RunAs /user:jbooze "CMD /C PowerShell -ExecutionPolicy ByPass -file D:\ABC.ps1"

    Change the username, file path, and shortcut icon accordingly.
      My Computer


  5. Posts : 15
    Windows 10 Pro Build 19042
       #34

    Add an image


    This is what I entered in the shortcut target box:

    RunAs.exe /user:John B "CMD /C PowerShell -ExecutionPolicy ByPass -file C:\Scripts\PowerShell\Microsoft.PowerShellISE_profile.ps1"

    When I select Apply it adds this to the shortcut target box and does not work:

    C:\WINDOWS\system32\

    I tried to add an image, that feature won't work for me. Is it supposed to accept a maximum of 5 per reply?
    Thank you.PowerShell Scripting - The Basics-psscut091820.png
    Last edited by jbooze; 18 Sep 2020 at 08:50. Reason: Add an image
      My Computer


  6. Posts : 7,607
    Windows 10 Home 20H2
       #35

    jbooze said:
    RunAs.exe /user:John B "CMD /C PowerShell -ExecutionPolicy ByPass -file C:\Scripts\PowerShell\Microsoft.PowerShellISE_profile.ps1"
    Your username John B contains a space, possibly the culprit. Try putting quotation marks around it.

    Code:
    RunAs.exe /user:"John B" "CMD /C PowerShell -ExecutionPolicy ByPass -file C:\Scripts\PowerShell\Microsoft.PowerShellISE_profile.ps1"
      My Computer


  7. Posts : 15
    Windows 10 Pro Build 19042
       #36

    I entered: Powershell.exe -noexit -ExecutionPolicy Bypass -File C:\Scripts\PowerShell\Microsoft.PowerShellISE_profile.ps1 as the target. It then added C:\Windows\System32\WindowsPowerShell\v1.0\ in front of this to make: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -ExecutionPolicy Bypass -File C:\Scripts\PowerShell\Microsoft.PowerShellISE_profile.ps1
    Then when I double-clicked it it opened PS and ran the program. Thanks for your help.
      My Computer


  8. Posts : 7,607
    Windows 10 Home 20H2
       #37

    You are most welcome.
      My Computer


  9. Posts : 11,062
    Windows 10 Pro version 22H2 0n one desktop and running Window 11 Pro 22H2 on unsupported desktop
       #38

    Ok Kari I am not savvy enough to follow through with any work using the PowerShell command as I am not intelligent to use scripting or coding languages but a good tutorial for those who do
      My Computer


 

Tutorial Categories

PowerShell Scripting - The Basics Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 06:35.
Find Us




Windows 10 Forums