run powershell script from anywhere

Question:

I am currently working on a powershell script. The objective of this script is to import data from a .csv file from which new users are created if that username does not already exist in the Active Directory.

My question is how can I make this script run from any location so all I have to do is type the name of the script and it will run. I have been able to do this in BASH but can’t figure out how to do this in power shell. So far google has been little help.

If it makes any difference i’m using Windows Server 2008 R2

Answer:

The basic idea is to create Powershell Function which will do the work (or will call other script placed in other location) and put this method to Profile.ps1 script (the script which is loaded everytime you start powershell) – Look at Windows PowerShell Profiles for further details.

Source:

run powershell script from anywhere by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply