Setting Windows PowerShell environment variables

Changing the actual environment variables can be done by using the env: namespace / drive information. For example, this code will update the path environment variable: There are ways to make environment settings permanent, but if you are only using them from PowerShell, it’s probably a lot better to use your profile to initiate the settings. On … Read more

How do you comment out code in PowerShell?

In PowerShell V1 there’s only # to make the text after it a comment. In PowerShell V2 <# #> can be used for block comments and more specifically for help comments. For more explanation about .SYNOPSIS and .* see about_Comment_Based_Help. Remark: These function comments are used by the Get-Help CmdLet and can be put before the keyword Function, or inside the {} before or after the code itself.

Connect-AzAccount – how to avoid azure device authentication?

1.To login with the user account, try the command as below, make sure your account doesn’t enable the MFA(Multi-Factor Authentication). 2.You can also use a service principal to login, use the command as below. See a similar issue I answered here, it use the old AzureRM module, for Az, just change the last line. If … Read more

How to run powershell script from .ps1 file?

Create a batch file which points at your .ps1 file. You may be required to run the batch file with elevated permissions, depending on your access levels (the logged in account will be used for execution). E.g.: If this still isn’t working, please execute your batch file via CMD (copying the path, wrapped in quotation … Read more

How to run a PowerShell script

Launch Windows PowerShell, and wait a moment for the PS command prompt to appear Navigate to the directory where the script lives PS> cd C:\my_path\yada_yada\ (enter) Execute the script: PS> .\run_import_script.ps1 (enter) What am I missing?? Or: you can run the PowerShell script from cmd.exe like this: according to this blog post here Or you … Read more