header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left
Random Cmdlets
New-ManagedFolder
Use the New-ManagedFolder cmdlet to create new managed folders for messaging records management (MRM). A managed folder is a folder in a user's mailbox to which MRM has been applied. The following are the managed folder types:


Remove-OABVirtualDirectory
Use the Remove-OABVirtualDirectory cmdlet to remove a server from the offline address book (OAB) distribution points list.


out-map
Creates a geographical or customized map for display or redistribution.


Move-Mailbox
Use the Move-Mailbox cmdlet to move mailboxes within your organization or between different organizations.


Test-EdgeSynchronization
Use the Test-EdgeSynchronization cmdlet to diagnose whether the subscribed Edge Transport servers have a current and accurate synchronization status.


Set-OwaVirtualDirectory
Use the Set-OwaVirtualDirectory cmdlet to modify the properties of Outlook Web Access virtual directories on a computer that is running Microsoft Exchange 2007 that has the Client Access server role installed.


Set-DistributionGroup
Use the Set-DistributionGroup cmdlet to modify the settings of an existing distribution group.


Get-IPAllowListProvidersConfig
Use the Get-IPAllowListProvidersConfig cmdlet to view the configuration information for the IP Allow List providers configuration on a computer that has the Edge Transport server role or the Hub Transport server role installed.


New-UMAutoAttendant
The New-UMAutoAttendant cmdlet creates a new Unified Messaging (UM) auto attendant.


Set-RecipientFilterConfig
Use the Set-RecipientFilterConfig cmdlet to enable and configure the Recipient Filter agent on a computer that has the Edge Transport server role or the Hub Transport server role installed.


  
Latest Scripts from PoshCode.org

SnapReminder
Remind the users of their snapshots - for use in VMware, see this post for more details: http://www.virtu-al.net/2009/06/22/powercli-snapreminder/

LibrarySqlBackup
Standalone script adapted from SQL Server Powershell Extensions (sqlpsx) http://sqlpsx.codeplex.com. Defines SQL Server backup and restore functions.

Format-TablePlus
This is a wrapper function for Format-Table that adds a @-Width@ parameter, and a @-PadEnd@ parameter (without which it trims the end of every line of output. Set -PadEnd to get the original Format-Table behavior of adding needless whitespace on the end of every line of output.

Colorize Subversion SVN
Colorize STAT, UPDATE and DIFF (without params) commands output for Subversion (svn) and Mercurial (hg). Here's a PowerShell functions that you can use to make those numerous commands you run every day via the PowerShell CLI a little easier to read by adding colors. Autodetect for svn or hg. Update autodetect to work with psdrives that are a UNC path. Also now works with repositorys in the root directory of drive. Added $args to each function so you can do things like sd -r2 -rtip -U0

Get-DirSize
A v2.0 function to recursively get the sizes of all subdirectories under a root path.

vProfiles
vProfiles V1.1 By Alan Renouf http://virtu-al.net, copies vSwitches and PortGroups from one host to another.

Prevent-Screensaver
Simulate user activity to prevent desktop lock or screensaver for specified period of time

TabExpansion for V2CTP3
The most needless, useless and worthless Tabexpansion for powershell.exe(v2.0CTP3) in PoshCode. Update: # Parameter name (and command alias) expansion with Ctrl+E ls -f *.txt -r | ? { $_.LastWriteTime -lt "2009/5" } | Select-String powershell -e OEM<Ctrl+E><tab>. <br> Get-ChildItem -Filter *.txt -Recurse | Where-Object { $_.LastWriteTime -lt "2009/5" } | Select-String powershell -Exclude OEM<tab> Get-ChildItem -Filter *.txt -Recurse | Where-Object { $_.LastWriteTime -lt "2009/5" } | Select-String powershell -Encoding OEM<tab> Get-ChildItem -Filter *.txt -Recurse | Where-Object { $_.LastWriteTime -lt "2009/5" } | Select-String powershell -ErrorAction OEM<tab><tab>...

TabExpansion
The most needless, useless and worthless Tabexpansion for powershell.exe(v1.0) in PoshCode. Please dot souce this script file to use. Update:. # WMI Namespaces expansion for Get-WmiObject gwmi -Namespace <tab>. Get-WmiObject -Namespace root\asp<tab>. # WMI Classes expansion which is corresponding to WMI Namespace (*) gwmi -Namespace ROOT\CIMV2\ms_409 -Class <tab>_<tab>. (*) it needs to remove old $PSHOME\WMIClasses.txt if it exists.

Parse nmap XML output
A PowerShell script into which one or more nmap XML output file objects can be piped, then the script emits synthetic objects representing port-scanned hosts from the XML file(s). Get Windows and Linux versions of the nmap scanner for free from http://nmap.org. Get a sample nmap XML file to play with and see some examples of using the script at https://blogs.sans.org/windows-security/2009/06/11/powershell-script-to-parse-nmap-xml-output/
  
 

April 24th, 2009.

Idera, one of our sponsors has joined forces with Don Jones to create some super PowerShell videos that you can find HERE.  Best of all...  They are FREE!

Follow the link above for more information.  Don Jones covers the basics of PowerShell, using PowerShell and Active Directory, using PowerShell and Exchange 2007, using PowerShell and SQL Server 2008, and using PowerShell to manage servers and clients.

The Community has just taken a great leap in getting the word out about how cool PowerShell is!

Marco Shaw - Co-Community Director

Community News
New sponsor: Compellent

PowerShellCommunity.org has an exciting new sponsor: Compellent.  Just added to our sponsors page:

Compellent is a leading provider of enterprise-class network storage solutions...

Microsoft TechDays Defy All Challenges

On April 1st, 2009, Microsoft is putting on a free 24 hour virtual event covering developer-related topics.

There will be 95 live sessions provided via Live Meeting in the following tracks:
*Windows Development and Frameworks
*Windows Mobile Development
*Office...

Microsoft releases IIS7 PowerShell snapin

The full details are HERE.  Microsoft has just released a production version of a IIS snapin for managing IIS7 on Windows Server 2008.  This snapin is independent of any features shipping with Windows Server 2008 R2 (like PowerShell...

New Sharepoint and SQL forums

Due to recent interest in the forum, we've added two new discussion areas:

PowerShell Expert Panel at TechEd EMEA 2008

 We are extremely proud of the the job that Jonathan Medd (of the Get-Scripting Podcast) did at TechEd EMEA 2008 with a panel discussion which was made possible by support from PowerShellCommunity.org. You can find the video on

  
Recent Blog Entries
Oct 19

Written by: Joe Brinkman
Friday, October 19, 2007 9:12 AM

As part of getting ready for my PowerShell session at OpenForce '07, I am creating a set of helper functions for working with SMO to manipulate and query the database server.  A common need when working with the database is to pass the username and password to various SMO methods.  When I first started coding my examples, I just passed a username and password as parameters into my functions.  This works, but does not exactly look professional when you are sitting in a presentation and typing out passwords in plaintext.

I decided that it would be better to use Get-Credential in this case since it would provide a professional dialog and keep the password hidden throughout the process.  Since I wanted to support both scenarios, I came up with the below function. 

function global:get-sqluser($username="", $password="") {
# We are creating an object to which we'll add custom properties
$user = New-Object Management.Automation.PSObject
 
if ($username -eq "") {
# No username was specified, so we should use Get-Credential to prompt for a user
# We also define a default username in order to suppress console output
# The results are added as synthetic properties to the PSObject we created above
$cred = Get-Credential "SqlUser"
$user.psobject.members.add( 
(New-Object System.Management.Automation.PsNoteProperty UserName, $cred.username.split("\")[1]) )
$user.psobject.members.add( 
(New-Object System.Management.Automation.PsNoteProperty Password, $Cred.Password) )
} Else {
# In this case we can just create synthetic properties using the values passed to the function
$user.psobject.members.add( 
(New-Object System.Management.Automation.PsNoteProperty UserName, $username) )
$user.psobject.members.add( 
(New-Object System.Management.Automation.PsNoteProperty Password, $password) )
}
 
# Return our synthetic object
$user
}

It is not perfect as the two cases return the password as either a cleartext string or a securestring.   Also, I don't like the hack with the Get-Credential since I don't really need a domain qualified name (notice the ugly split("\")[1] that is needed to get just the username without a domain qualifier).  My next version will resolve both of these issues, but for now this will have to suffice.

Tags:

Re: Getting a Username/Password in PowerShell

We can add member to object using the built-in add-member cmdlet:

$user | add-member -name UserName -value $cred.username.split("\")[1] -membertype NoteProperty
$user | add-member -name Password -value $cred.password -membertype NoteProperty

By aleksandar on   Tuesday, October 16, 2007 6:25 PM

Re: Getting a Username/Password in PowerShell

See my next blog entry for the reason why I don't use add-member in this case.

By jbrinkman on   Wednesday, October 17, 2007 7:47 AM

Re: Getting a Username/Password in PowerShell

Yeah, I was going to comment on the code formatting, but it seems you noticed and fixed it.

By marco.shaw on   Thursday, October 18, 2007 5:59 PM

Re: Getting a Username/Password in PowerShell

$cred.GetNetworkCredential().username will give you just the username without a domain qualifier.

By aleksandar on   Monday, November 05, 2007 11:48 AM

Re: Getting a Username/Password in PowerShell

@Alesandar - Thanks for the info. This really highlights the need for maintaining consistency across APIs. I am used to web APIs in .Net which decompose objects properties on the top level object without requiring further method calls. You live and you learn I guess.

By jbrinkman on   Monday, November 05, 2007 11:51 AM
  

PowerShellCommunity is sponsoring this year's Microsoft Technet Scripting Games, along with the new PoshCode.org. Submit your entry today!

right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer