After playing with powershell for a while I got tired of typing the username and password every time I wanted to access a remote PC or server. There is an attriubute called PSScredentials and allow you to cache your credentials and passthem to your scripts. Here is a basic example
[sourcecode language=”css”]
# Define the Credentials
# Define the Username
$user = Read-host -Prompt "Type your username. Ex user1 or Domainuser1 or user@domain.com"
# Define the secure password
$pass = Read-host -Prompt "Type your password" -AsSecureString
# Define Credentials
$mycreds = New-Object System.Management.Automation.PSCredential ($user,$pass)
# Pass $mycreds variable to any PowerShell Commandlet that support PScredentials value.
[/sourcecode]