This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Header = @" | |
<style> | |
TABLE {border-width: 1px; border-style: solid; border-color: black; border-collapse: collapse;} | |
TH {border-width: 1px; padding: 3px; border-style: solid; border-color: black; background-color: #6495ED;} | |
TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black;} | |
</style> | |
"@ | |
$smtphost = "smtp.domain.com" | |
$from = "AutomatedAgent@domain.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$server = Read-Host "Please provide the server name" | |
$InstanceId = (Get-EC2Instance | ?{$_.Instances.tag.value -like $server}).Instances.InstanceId | |
$deviceids = (Get-EC2InstanceAttribute -InstanceId $InstanceId -Attribute blockDeviceMapping | Select -ExpandProperty BlockDeviceMappings).DeviceName | |
foreach($deviceid in $deviceids) | |
{ | |
Edit-EC2InstanceAttribute -InstanceId $InstanceId -BlockDeviceMapping @{DeviceName=$deviceid;Ebs=@{DeleteOnTermination=$true}}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-Device() { | |
param( | |
[parameter (mandatory=$true)][string] $InstanceId | |
) | |
$CurrentDevice = Get-EC2InstanceAttribute $InstanceId -Attribute blockDeviceMapping | Select-Object -ExpandProperty BlockDeviceMappings | Select-Object -last 1 | |
If ($CurrentDevice.DeviceName -eq '/dev/sda1') { | |
$NewDevice = 'xvdf' | |
return $NewDevice | |
} | |
Else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[parameter(mandatory=$true,HelpMessage="Please enter EC2 Instance Name")][string] $InstanceName, | |
[parameter(mandatory=$true)][int] $VolumeSize, | |
[parameter(mandatory=$false)][string] $Device, | |
[parameter(mandatory=$true)][string] $VolumeType | |
) | |
$Filter = New-Object Amazon.EC2.Model.Filter | |
$Filter.Name = 'tag:Name' | |
$Filter.Value = "$InstanceName" | |
$Reservation = Get-EC2Instance -Filter $Filter | Select-Object -ExpandProperty instances |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Initialize-EC2Disk { | |
param( | |
[parameter (mandatory=$true)][string] $InstanceId | |
) | |
$Commands = @( | |
'Get-Disk | ` | |
Where partitionstyle -eq "raw" | ` | |
Initialize-Disk -PartitionStyle MBR -PassThru | ` | |
New-Partition -AssignDriveLetter -UseMaximumSize | ` | |
Format-Volume -FileSystem NTFS -Confirm:$false -force' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Connect-VIServer vcentername | |
$compName = Read-Host "Please provide the Server Name" | |
$inputdrive = Read-Host "Please provide the drive letter that needs to be extended" | |
$inputdrive1 = $inputdrive + ":" | |
[int]$sizetoincrease = Read-Host "Please provide the size you want to increase in GB" | |
$snapshot = Get-Snapshot -VM $compName | |
if(!$snapshot) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Results = @() | |
$servers = Get-Content C:\Script\list.txt | |
foreach($server in $servers) | |
{ | |
Try | |
{ | |
$Manufacturer = Get-WmiObject WIn32_computerSystem -ComputerName $server -ErrorAction Stop | Select -ExpandProperty Manufacturer | |
} | |
Catch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$servers = Get-ADComputer -Filter { OperatingSystem -like "*Windows Server*"} | Select -ExpandProperty Name | |
Write-Host " Total No of Server Objects found in AD - $($servers.Count) " -ForegroundColor Cyan | |
$Results = @() | |
foreach($server in $servers) | |
{ | |
If (Test-Connection $server -Count 1 -ErrorAction SilentlyContinue) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Results = @() | |
Import-AzContext -Path C:\Users\Script\test.json | |
$subscriptions = Get-AzSubscription | Select -ExpandProperty Id | |
foreach($subscription in $subscriptions) | |
{ | |
Set-AzContext -Subscription $subscription | Out-Null | |
$Details = Get-AzDisk | ?{$_.DiskState -eq "Unattached"} | |
$Details.Name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Results = @() | |
$Details = Get-VM | Select Name, PowerState, GuestId, @{N="VM Config File";E={$_.extensiondata.config.files.vmpathname}} | |
$Network = get-vm | Get-NetworkAdapter |Select -ExpandProperty NetworkName | |
$Properties = @{ | |
VMName = $Details.Name | |
PowerState = $Details.PowerState | |
GuestId = $Details.GuestId | |
'VM Config File' = $Details.'VM Config File' | |
Network = $Network | |
} |
NewerOlder