cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
555
Views
1
Helpful
3
Replies

UCS Central PowerTool - PowerShell Script to Find Server Domain

zbroinx
Level 1
Level 1

Hi,

Does anyone know of way to get the domain from a server through PowerShell using the UCS PowerTool?
I have a lot of domains, so 
I'm using code bellow to connect to UCS central, and search for a server. The idea is connect the domain and clean the SEL logs, but I need the domain where the server is.

$ucscred=Get-Credential
$UCSCentral="ucs_central_url"
Connect-UcsCentral -credential $ucscred $UCSCentral
$servers=Get-UcsCentralServer
Disconnect-UcsCentral

foreach($srv in $servers){

if ($srv.UsrLbl -eq "server_name"){
Write-Host "Found!"
}
}

 

 

1 Accepted Solution

Accepted Solutions

 

It looks like

  • The Domain name is not a property of the Server that is returned by Get-UcsCentralServer. The closest I see is the Domain ID in Central

Dn : compute/sys-1001/chassis-1/blade-8

  • The Domain ID can be looked up using

Get-UcsCentralUcsDomain | select Name,Id | sort Name

  • You are looking up by user label on the server. Is looking up by Service Profile name an option? If so, you could try

Get-UcsCentralServiceProfile | ? { $_.Name -eq "SP_name" }| select Name, UsrLbl, Domain

  • If you want to look up by User Label on the Service Profile (and the field is populated), using your script as an example, I think the following may work (but I have not tested it, since we don't use user labels on SPs)

$SPs = Get-UcsCentralServiceProfile
foreach ( $SP in $SPs ) {
if ( $_.UsrLbl -eq "server_label") {
$domain = $_.Domain
Write-Host "The domain for the server is $domain"
}
}

Note: Our Service Profile names and our VMware host names are aligned, which makes it very easy to combine PowerTool and PowerCLI commands against the same objects ( UCS SPs and VMware hosts).

View solution in original post

3 Replies 3

marce1000
VIP
VIP

 

           - Try this : 

   $ucscred = Get-Credential
   $UCSCentral = "ucs_central_url"
   Connect-UcsCentral -credential $ucscred $UCSCentral
   $servers = Get-UcsCentralServer
   Disconnect-UcsCentral

   foreach ($srv in $servers) {

   if ($srv.UsrLbl -eq "server_name") {
   $domain = $srv.AssignedToDn
   Write-Host "The domain for the server is $domain"
}
}

 M.



-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
    When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '

Unfortunately, that field doesn't get me the domain name:
AssignedToDn : org-root/org-test/ls-servername

 

It looks like

  • The Domain name is not a property of the Server that is returned by Get-UcsCentralServer. The closest I see is the Domain ID in Central

Dn : compute/sys-1001/chassis-1/blade-8

  • The Domain ID can be looked up using

Get-UcsCentralUcsDomain | select Name,Id | sort Name

  • You are looking up by user label on the server. Is looking up by Service Profile name an option? If so, you could try

Get-UcsCentralServiceProfile | ? { $_.Name -eq "SP_name" }| select Name, UsrLbl, Domain

  • If you want to look up by User Label on the Service Profile (and the field is populated), using your script as an example, I think the following may work (but I have not tested it, since we don't use user labels on SPs)

$SPs = Get-UcsCentralServiceProfile
foreach ( $SP in $SPs ) {
if ( $_.UsrLbl -eq "server_label") {
$domain = $_.Domain
Write-Host "The domain for the server is $domain"
}
}

Note: Our Service Profile names and our VMware host names are aligned, which makes it very easy to combine PowerTool and PowerCLI commands against the same objects ( UCS SPs and VMware hosts).

Review Cisco Networking for a $25 gift card

Review Cisco Networking for a $25 gift card