header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left
Random Cmdlets
Get-Item
Gets the item at the specified location.


Move-ClusteredMailboxServer
This topic explains how to use the Move-ClusteredMailboxServer cmdlet to transfer a Microsoft Exchange Server 2007 clustered mailbox server (CMS) to an available passive cluster node.


Remove-SDMgpo
Deletes a GPO from a domain


Remove-SDMgpoSecurity
Removes a permission (ACE) from a GPO


Add-History
Appends entries to the session history.


Get-MailboxStatistics
Use the Get-MailboxStatistics cmdlet to obtain information about a mailbox, such as the size of the mailbox, the number of messages it contains, and the last time it was accessed.


Disable-OutlookAnywhere
The Disable-OutlookAnywhere cmdlet disables Outlook Anywhere on the computer that is running Microsoft Exchange Server 2007 that has the Client Access server role installed.


Get-LogonStatistics
Use the Get-LogonStatistics cmdlet to retrieve logon statistics, such as user name, logon time, last access time, client version, and adapter speed.


Get-AcceptedDomain
Use the Get-AcceptedDomain cmdlet to view the configuration information for the accepted domains that are configured in your organization. You can view the accepted domain configuration from inside the Exchange organization or from a computer that has the Edge Transport server role installed in a Microsoft Exchange Server 2007 organization. For more information about how to configure an accepted domain, see Set-AcceptedDomain.


Import-Csv
Imports comma-separated value (CSV) files in the format produced by the Export-CSV cmdlet and returns objects that correspond to the objects represented in that CSV file.


  
Latest Scripts from PoshCode.org

Exch07 Quota Report
Power Shell 1 script used to grab mailbox stats for a Exchange 2007 server. It saves the information into a .csv file by changing the $OUTFILE variable. The script is pretty basic but it's a simple way of having a history of how people use their inbox space. There is no method for managing the saved files. I just make it a point to delete them when I run my months end maintenance.

Out-DataTable
Creates a DataTable for an object, based on script by Marc van Orsouw

Modified WOL impl.
This function can send WOL packages. Note that this a modified version of code already floating online. You need to specify the Mac address as a string. Optionally use -Ports (0,1000) to specify the udp ports. (use -verbose to show which pacakges are being send).

Invoke-SqlCmd2
Modeled after SQL Server 2008 Invoke-Sqlcmd, but fixes bug in QueryTimeout.

EchoTest.cmd
A DOS cmd script to show how your arguments look to "native" console apps

Set account password
This script will allow you to set the password for an account on a local or remote machine/s. A report is then generated when done along with an error log. Scripts accepts pipeling input for the computer/s. If any errors are encountered, a log will be generated as well.

Enable/Disable FusionLog
http://georgemauer.net/blog/enabledisable-fusionlog-powershell-script/ Enabling/disabling your Fusion Log every time you need to figure out why assembly binding has gone wrong is a hassle. So here you go.

Start-Presentation
My current (WPF 4 compatible) PowerBoots-based Presentation Module. *REQUIRES* "PresentationFrame.xaml":http://poshcode.org/get/2104 and, of course, "PowerBoots":http://boots.codeplex.com This isn't really ready to be shared, but I always tell people if you wait until after you have time to clean it up, you'll never share it -- so since I'm unlikely to actually finish cleaning this up any time soon -- here it is. "See the screenshots for an example":http://HuddledMasses.org/images/PowerBoots/PowerBoots%2dPresentation.png

PresentationFrame.xaml
A required file for my "PowerShell Presentation module":http://poshcode.org/2105

Get-RemoteRegistry
A script to do a query on a remote registry key or value. Because the Registry provider inexplicably doesn't support it.
  
 

April 5th, 2010,

The 2010 Scripting Games are coming...

2010 Scripting Games

 Fire up your scripting editor and get ready to write some PowerShell!

Check out the Study Guide and register for the games!

-Steven Murawski
Co-Community Director

Community News
iPowerShell V2 Now Available

Sapien just released iPowerShell V2, which is now available in the Apple app store.  What is iPowerShell?

From Ferdinand Rios -

PowerShell In Practice

From Marco Shaw -

Check out http://www.manning.com/siddaway

Get the ebook or printed edition (not available yet), and use the discount code "marcoshell40" when checking out and get 40% off the regular...

Thomas Lee Joins PoshComm Directors

PowerShellCommunity.Org is happy to announce that Thomas Lee, Powershell MVP and noted trainer, is joining our ranks as a Community Director. 

Thomas is also responsible for a good many of the PowerShell...

Looking to get started with Modules?

Check out the PowerShellPack from James Brundage, which contains modules for making GUI's, add-ons for the ISE(Integrated Script Editor), system tools, and...

PowerShell Virtual Launch Party

PowerShell V2 Virtual Launch Party!

Jeffrey Snover, Hal Rottenberg and Jonathan Walz (hosts of the PowerScripting Podcast) hosted a PowerShell V2 Virtual Launch Party on Thursday, Oct 22nd, 9:30 PM EDT (GMT-4). 

More details...

  
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
  

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

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