I have had a few comments and e-mails recently from people having problems running the PowerShell scripts published on this site as PS1 files in the Management Shell console application included with SharePoint 2010. Unfortunately, PS1 files do not run like batch (.BAT) files used to by simply typing the name of the file.
Personally, I prefer to use Windows PowerShell ISE that ships with PowerShell 2.0 or Windows 7/Server 2008 R2 for developing and running scripts (see here for details on how to use this with SharePoint 2010), but for those that wish to use the Management Shell, launch it from the start menu and type the following syntax to run a script file:
….and hit the return key. To clarify, that is [dot][space][script name in single quotes]. The quotes allow you to use spaces in your script names, if desired.
The script will either run there and then, or if it is written as a function, you can then call the function using its name and any associated switches. For example, here a screenshot to demonstrate the function that I posted here to check the size of a site hierarchy in SharePoint 2010:
Note that the first line loads the function from a PS1 file and the second line kicks off the script by calling the GetWebSizes function with the StartWeb switch.