Email dw Contents About dw
[Company Logo Image]

at The Data Center

"A space for AD, Exchange and other technical stuff"

 

 -- Where Information Technology Lives!  --

 


 

How to download and install powershell.
http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx
 
When you create your cmdlet with notepad, name the file with a .ps1 extension.
By default your computer policy may be set to not allow powershell scripts to run. To change the PowerShell Execution Policy you can execute the following from within the PowerShell command window:
 
Set-ExecutionPolicy RemoteSigned
 
Or you can change the Execution Policy via the registry by navigating to the following:
 
HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
 
Then locate ExecutionPolicy and add the value from the list below:
 
Restricted
AllSigned
RemoteSigned
Unrestricted
 
For example if you want to set your PowerShell execution policy for RemoteSigned add the following:
 
HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
"ExecutionPolicy"="RemoteSigned"
 
Here you will find a list of the available PowerShell execution policies with a brief description of each:
 
AllSigned
All scripts as well as configuration files must be signed by a trusted publisher. This includes script on the local as well as remote machines. 
 
Default
Uses the default Restricted policy. 
 
RemoteSigned
All scripts as well as configuration files downloaded via the Internet must be signed by a trusted publisher. 
 
Restricted
As mentioned this is the PowerShell default and will not allow you to execute scripts or load configuration files.  
 
Unrestricted
This allows you to execute all scripts as well as load configuration files however if you download a script from the internet you are prompted to approve it before it can execute.
 
I had a hard time getting the knack of not adding the “&” or “+” and putting the variables directly in line.

 

vbscript = "\\" & vStrcomputer & "\" & vPath
powershell = “\\$strcomputer\$vpath”

 

get-content will show the script similar to opening it in a text editor so running these two commands

set-location c:\scripts\

get-content exampleScript.ps1

 

Would show the content of c:\scripts\exampleScripts.ps1 as output in the command window.

 

After the set-location

dir *.ps1 would show a list of all scripts.

 

 

Change the first letter of a string to uppercase

$str="powershell"
$str= "{0}{1}" -f $str.substring(0,1).toUpper(), $str.substring(1).toLower()