Rename Services & Application in Failover Cluster Manager Using Powershell - powershell

PS C:\Users\sup> Get-ClusterGroup | Where-Object {$_.name -ilike "*scvmm*"}
Name Owner State
---- --------- -----
scvmm..rtrtry.exported n01 Offline
scvmm..rtrtry566.exported n02 Offline
Hi All, i wanted to rename the services & application in Failover cluster manager which have the words scvmm & exported in it using powershell, for example the above names should be changed to ..rtrtry. & ..rtrtry566., could some one help me out?

You can get the objects you want with a regex match and set the name property:
get-clustergroup |
where {$_.Name -match "scvmm\.(.*)\.exported"} |
foreach {$_.Name = $matches[1]}

Related

SCOM 2012 Windows Service Monitoring Target object

How can I find name of group targeted a windows service monitor which created with template using Powershell?
I mean, I created a monitor in scom using template, I am checking a service. I targeted the monitor to a group. I want to find group name with Powershell.
I wants to get target information on windows service template. How can I get this using Powershell?
To retrieve the target ID for 'All Windows Computers' , execute $targetID = Get-SCOMClassInstance -Class (Get-SCClass | Where-Object DisplayName -Like 'All Windows Computers') | Select ManagementPackClassIds.
Then use the target ID to query ' Get-SCOMMonitor | Select-Object -First 1 | where-object DisplayName -eq 'Queries With High Fetches' | where-object Target -like 'ManagementPackElementUniqueIdentifier=$targetID*'` and see what you get. This is just how you could go about it. Please note that you might have to perform the some string interpolation to get this to work with $targetID.

Fetching net use details

I am using net use to get the Windows mount path and drive.
PS C:\Users\jagg> net use
New connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
OK Y: \\ITHANSJJA001.ABC.COM\opmas$
Microsoft Windows Network
The command completed successfully.
I would like to fetch the drive and mount path detail using PowerShell command. Is there any way to get it using only PowerShell?
you seem to be confused about what powershell is able to do. [grin]
however, here are two ways to get the info you seem to want. the 1st parses the output of net use while the 2nd uses Get-PSDrive to get that same info natively.
(net use) -replace '\s{2,}', ',' |
Select-String -SimpleMatch '\\' |
ConvertFrom-Csv -Header 'Status', 'DriveLetter', 'MountPath', 'Network' |
Select-Object -Property DriveLetter, MountPath
''
Get-PSDrive -PSProvider FileSystem |
# the 4 slashes are 2 regex-escaped slashes
Where-Object {$_.DisplayRoot -match '\\\\'} |
ForEach-Object {
[PSCustomObject]#{
DriveLetter = '{0}:' -f $_.Name
MountPath = $_.DisplayRoot
}
}
hope that helps,
lee

Powershell Script to fetch netback client and SMTP relay

Is there anyway to fetch value for "netbackup client version" and "whether the server requires SMTP relay or not" using powershell script? Below script I used to get the citrix version in the windows server not sure how to get the other values.
powershell "$Citrix=(Get-WmiObject -Class Win32_Product | Sort-object Name | select Name, version | Where { $_.Name -match 'Citrix'}).version -join ',';Write-Host "Citrix = $Citrix";' '"
Dependent services can be looked up with Get-Service cmdlet. I don't have Netback, so let's use Sql Server as an example. The Agent depends on Sql Server like so,
Get-Service -Name 'SQLAgent$SQLI001' -RequiredServices
Status Name DisplayName
------ ---- -----------
Stopped MSSQL$SQLI001 SQL Server (SQLI001)
As for how to get the software version, see if the binary contains the version. This approach requires you to know the binary path. Like so,
(Get-ChildItem E:\MSSQL12.SQLI001\MSSQL\Binn\SQLAGENT.EXE).VersionInfo | Select-Object -Property ProductVersion,FileVersion
ProductVersion FileVersion
-------------- -----------
12.0.5207.0 2014.0120.5207.00 ((SQL14_PCU_main).170703-0132 )

Powershell command to List the services on a specific/individual cluster node

How to find the list of service on a specific node in a given cluster using Powershell?
There are 2 nodes in this cluster group ServerName_1 and ServerName_2, I am trying to fetch the services on Server_name1.
I have tried running the below commands but I did not get any output or error.
I tried using the below command and I could get the results:
PS C:\Users\sd> Get-ClusterGroup | Where-Object {$_.State -EQ "Online"}
Name OwnerNode State
---- --------- -----
Service_1 ServerName_1 Online
Service_2 ServerName_2 Online
However, when i tried to extract the OwnerNode using the same command i do not see any result , as observed below:
PS C:\Users\sd> Get-ClusterGroup | Where-Object {$_.OwnerNode -EQ <ServerName_1>}
PS C:\Users\sd>
As I do not see any output, I am not sure whether the command i executed is correct?
I need this, so that I may start the specific service on ServerName_1 alone.
PS C:\Users\sd> Start-ClusterGroup -Name <ServiceName> | Where-Object
{ $_.OwnerNode -eq "<ServerName1>" }
PS C:\Users\sd>
You don't need the < > in your code, update
Get-ClusterGroup | Where-Object {$_.OwnerNode -EQ <ServerName_1>}
to
Get-ClusterGroup | Where-Object {$_.OwnerNode -EQ "ServerName_1"}
I tested this and it works as expected:
List the ClusterGrop Names-
Get-ClusterNode -Name "Server_name" | Get-ClusterGroup
Also,
List the ClusterGroup Services -
Get-ClusterNode -Name "Server_name" | Get-ClusterResource

How to check if a particular service is running in a remote computer using PowerShell

I have 3 servers, running 3 services:
SERVER-A running serv1.exe service
SERVER-B running serv2.exe service
SERVER-C running serv3.exe service
Using PowerShell how can I query each service to check if they are running and output the information to a text file?
If they all have the same name or display name you can do it in one command. If not you need to run 3 commands.
If all have the same name or display name:
Get-Service -ComputerName server-a, server-b, server-c -Name MyService |
Select Name, MachineName, Status
If they have different names or display names:
I would do this --
#{
'server-a' = 'service-a'
'server-b' = 'service-b'
'server-c' = 'service-c'
}.GetEnumerator() | ForEach-Object {
Get-Service -ComputerName $_.Name -Name $_.Value
} | Select Name, MachineName, Status
To output to a text file use ... | Set-Content ~\Documents\Service_Status.txt where ... is one of the above.
Note - your account will need to have privileges to query the remote machines.
There are several ways to achieve this. I am using a hash of the values since you mentioned that the server to service mapping is always one to one.
$svrHash = #{"SERVER-01"="winmgmt";"SERVER-02"="Wecsvc"}
$svrHash.Keys
| ForEach-Object {Get-Process -ComputerName $_ -Name $svrHash[$_] -Ea SilentlyContinue}
| Select ProcessName
| Out-File C:\Scripts\test.txt
You need to use the service name and not the .exe name.