The following snippet assumes that a New Hyper-V Server has been added to the cluster; yet, it’s SCVMMAgent Service doesn’t get installed or is corrupted such as:
PS C:\Windows\system32> get-service SCVMMAgent
get-service : Cannot find any service with service name 'SCVMMAgent'.
At line:1 char:1
+ get-service SCVMMAgent
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (SCVMMAgent:String) [Get-Service], ServiceCommandException
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
# Version 0.01
# No robot crawler to locate the highest VMMAgent version automatically (will code that when I feel like it)
# Install VMM Agent
$vmmServer='vmmServerName'
$version='10.19.2591.0'
$agentMsiFile="\\$vmmServer\C$\Program Files\Microsoft System Center\Virtual Machine Manager\agents\amd64\$version\vmmAgent.msi"
# Installing VMM Agent using its MSI File
$file=gi $agentMsiFile
$DataStamp = get-date -Format yyyyMMddTHHmmss
$logFile ="C:\" + '{0}-{1}.log' -f $file.name,$DataStamp
$MSIArguments = @(
"/i"
('"{0}"' -f $file.fullname)
"/qn"
"/norestart"
"/L*v"
$logFile
)
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
Categories: