- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 07:45 AM
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!"
}
}
Solved! Go to Solution.
- Labels:
-
UCS PowerTool
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 09:55 AM
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 07:59 AM
- 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! '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 08:10 AM
Unfortunately, that field doesn't get me the domain name:
AssignedToDn : org-root/org-test/ls-servername
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 09:55 AM
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).
