Thursday, October 7, 2021

Azure Powershell change dynamic ip to static for a VM.

 

Select-AzContext -Subscription "YourSubscriptionname"

 

get-azsubscription to get a list of all subscriptions you have access to.

 

Set-AzContext  -subscriptionname "yoursubscriptionname"

 

 Change dynamic to static for a single VM

$If = Get-AzNetworkInterface | ?{$_.virtualmachine.id -match "yourvm"}
$Nic = Get-AzNetworkInterface -ResourceGroupName $If.resourcegroupname -Name $if.name
$Nic.IpConfigurations[0].PrivateIpAllocationMethod
$Nic.IpConfigurations[0].PrivateIpAllocationMethod = "Static"
Set-AzNetworkInterface -NetworkInterface $Nic

 

View all Vm's with dynamic ip's

$DynamicIfs = Get-AzNetworkinterface | ?{$_.IpConfigurations[0].PrivateIpAllocationMethod -eq "Dynamic"}
foreach($if in $DynamicIfs)
{
$Nic = Get-AzNetworkInterface -ResourceGroupName $If.resourcegroupname -Name $if.name
Write-host $If.Virtualmachine.Id $Nic.IpConfigurations[0].PrivateIpAllocationMethod
}

 

Change dynamic to static for all VM's. 

$DynamicIfs = Get-AzNetworkinterface | ?{$_.IpConfigurations[0].PrivateIpAllocationMethod -eq "Dynamic"}
foreach($if in $DynamicIfs)
{
$Nic = Get-AzNetworkInterface -ResourceGroupName $If.resourcegroupname -Name $if.name
$Nic.IpConfigurations[0].PrivateIpAllocationMethod
$Nic.IpConfigurations[0].PrivateIpAllocationMethod = "Static"
Set-AzNetworkInterface -NetworkInterface $Nic
}



Friday, September 17, 2021

Remote server administration tools not installing.

 The option to enable windows administrations tools is missing.

 

 

 

Install powershell 7 and run the following command.


Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability -Online

Download powershell 7 from here.

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-7.1



Tuesday, June 15, 2021

Adding recovery task in SCOM for service start

 This is for the SQL management pack. But can be applied to any management pack which discovers the service name and monitors it.

Open the settings of the monitor and click add command recovery for your health state.

Full Path to file:

%windir%\system32\net.exe

Parameters:

start $Target/Property[Type="MicrosoftSQLServer2016Discovery7040!Microsoft.SQLServer.2016.Agent"]/ServiceName$

Working Directory:

%windir%\system32