Skip to content

Instantly share code, notes, and snippets.

View mczerniawski's full-sized avatar

mczerniawski mczerniawski

View GitHub Profile
$BitLockerVolumes = Get-BitLockerVolume
foreach ($blv in $BitLockerVolumes) {
BackupToAAD-BitLockerKeyProtector -MountPoint $blv.MountPoint -KeyProtectorId (($blv.KeyProtector)[1] | Select-Object -ExpandProperty KeyProtectorID)
}
ComputerName: NBMCZERNIAWSKI2
VolumeType Mount CapacityGB VolumeStatus Encryption KeyProtector AutoUnlock Protection
Point Percentage Enabled Status
$BitLockerVolumes = Get-BitLockerVolume
foreach ($blv in $BitLockerVolumes) {
Backup-BitLockerKeyProtector -MountPoint $blv.MountPoint -KeyProtectorId (($blv.KeyProtector)[1] | Select-Object -ExpandProperty KeyProtectorID)
}
ComputerName: NBMCZERNIAWSKI2
VolumeType Mount CapacityGB VolumeStatus Encryption KeyProtector AutoUnlock Protection
Point Percentage Enabled Status
$Computers = Get-ADComputer -filter * -SearchBase 'OU=Servers,OU=ComputersX,DC=contoso,DC=com' | Select-Object -ExpandProperty Name
$Allcerts = Invoke-Command -ComputerName $Computers -ScriptBlock {
Get-childItem Cert:\LocalMachine\My | Select-Object DnsNameList,NotBefore,NotAfter,Thumbprint,Issuer,Subject
} -ErrorAction SilentlyContinue
#region get all certs that expired
#get current date
$date = Get-Date
$Computers = Get-ADComputer -filter * -SearchBase 'OU=Servers,OU=ComputersX,DC=contoso,DC=com' | Select-Object -ExpandProperty Name
$Allcerts = Invoke-Command -ComputerName $Computers -ScriptBlock {
Get-childItem Cert:\LocalMachine\My | Select-Object DnsNameList,NotBefore,NotAfter,Thumbprint,Issuer,Subject
} -ErrorAction SilentlyContinue
#region get the cert we're looking for
$thumbprint = 'PLACEYOURTHUMBPRINTHERE'
$AdComputerFilter = 'DNSHostName','lastLogon','lastlogontimestamp','operatingSystem','operatingSystemVersion','whenChanged','whenCreated'
$SelectObjectFilter = @(
'DNSHostName',
@{name='lastLogon';e={[datetime]::FromFileTime($PSItem.'lastLogon') }},
@{name='lastLogontimestamp';e={[datetime]::FromFileTime($PSItem.'lastLogontimestamp') }},
'operatingSystem','operatingSystemVersion','whenCreated','whenChanged','DistinguishedName',
@{name='InUse';e={''}},
@{name='CurrentAccessList';e={''}},
@{name='Applications';e={''}},
$AdComputerFilter = 'DNSHostName','lastLogon','lastlogontimestamp','operatingSystem','operatingSystemVersion','whenChanged','whenCreated'
$SelectObjectFilter = @(
'DNSHostName',
@{name='lastLogon';e={[datetime]::FromFileTime($PSItem.'lastLogon') }},
@{name='lastLogontimestamp';e={[datetime]::FromFileTime($PSItem.'lastLogontimestamp') }},
'operatingSystem','operatingSystemVersion','whenCreated','whenChanged','DistinguishedName',
@{name='InUse';e={''}},
@{name='CurrentAccessList';e={''}},
@{name='Applications';e={''}},
Get-ADComputer -Filter * -SearchBase 'OU=Servers,OU=Computers,DC=contoso,DC=com' -properties 'operatingSystem','whenCreated','whenChanged'
Get-ADComputer -Filter * -SearchBase 'OU=Servers,OU=Computers,DC=contoso,DC=com' -Properties 'DNSHostName','lastLogon','lastlogontimestamp','operatingSystem','operatingSystemVersion','whenChanged','whenCreated' | Select-Object 'DNSHostName',
@{name='lastLogon';e={[datetime]::FromFileTime($PSItem.'lastLogon') }},
@{name='lastLogontimestamp';e={[datetime]::FromFileTime($PSItem.'lastLogontimestamp') }},
'operatingSystem','operatingSystemVersion','whenCreated','whenChanged','DistinguishedName',
@{name='InUse';e={''}},
@{name='CurrentAccessList';e={''}},
@{name='Applications';e={''}},
@{name='SystemUpdate';e={''}},
@{name='PM';e={''}},
@{name='TO';e={''}}
$VMName = 'SomeVM'
$GUID = Get-VM $VMName | Select-Object -ExpandProperty id | Select-Object -ExpandProperty Guid
$processID = Get-Process vmwp -IncludeUserName | Where-Object {$_.Username -match $GUID} | Select-Object -ExpandProperty ID
$VMName = 'SomeVM'
#Get VM disk path. Assuming there's only one VHD here
$VHDPath = Get-VMHardDiskDrive $VMName | Select-Object -ExpandProperty Path
#Verify VHD information, including current size
Get-VHD -Path $VHDPath
#Expand the disk
$newSize = 120GB
Resize-VHD -Path $VHDPath -SizeBytes $newSize