Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just grab property and not label

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
US
When I execute the following command
Code:
$cs = Get-ClusteredMailboxServerStatus|FL Identity
I get the following output when I view $cs
Identity : DIAMONDEXCHANGE

This is returning the right information but I need for my variable to not incluse the "Identity :" part. Anyone know how to grab just the value of a property? I'd appreciate a sample.

Thanks

Mark
 
Figured it out:

Code:
$cs = Get-ClusteredMailboxServerStatus|%{$_.Identity}|%{$_.Name}

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
You can also do something like

$CMSArray = @(Get-ClusteredMailboxServerStatus)
ForEach ($CMS in $CMSArray){
write-host $CMS.Identity
}

Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
Thanks Pat, I'll give that a try when I am in the office Monday to see how that works out.

I needed this so I could write a script (VBScript) that launches PowerShell to move the Active Node of the cluster. PowerShell does all the work, but I wanted double click capabilities so I am using VBScript to fire off the PowerShell.

For anyone else that is interested. Just run this script on a node of your cluster that s not the Active Node. This will transfer the Active Node to that system.

Code:
'==========================================================================
'
' NAME: MoveCluster.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : //2009
' COPYRIGHT © 2009, All Rights Reserved
'
' COMMENT: 
'    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
'    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
'    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'==========================================================================

Set WSHNetwork = CreateObject("Wscript.Network")
Set WSHShell = CreateObject("Wscript.Shell")

ComputerName = WSHNetwork.ComputerName
Reason = InputBox("Enter reason for moving cluster active node")

PSCmd0 = "Start-Sleep 3;Write-Host 'Adding Exchange Snapin';add-pssnapin *.Exchange*;"
PSCmd1 = "Start-Sleep 3;Write-Host 'Getting Cluster Name';"
PSCmd2 = "$cs = Get-ClusteredMailboxServerStatus|%{$_.Identity}|%{$_.Name};"
PSCmd3 = "Write-Host 'Cluster:'$cs;Write-Host 'Moving Cluster Active Node To:'" & ComputerName & ";"
PSCmd4 = "Move-ClusteredMailboxServer -Identity $cs -Target " & ComputerName & " -MoveComment '" & Reason & "' -Confirm:$false;"
PSCMd5 = "Write-Host 'Getting Cluster Status';Get-ClusteredMailboxServerStatus"
WSHShell.run "Powershell -noexit -command " & chr(34) & PSCmd0 & PSCmd1 & PSCmd2 & PSCmd3 & PSCmd4 & PSCmd5

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top