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($Comp = 'localhost') (gwmi Win32_OperatingSystem -Comp $Comp | select PSComputerName, ServicePackMajorVersion, Version, @{l='BIOSSerial';e={gwmi Win32_BIOS -Comp $Comp | select -expand SerialNumber}} | Out-String).Replace("`n","`t`t`t").TrimStart() |
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
Get-EventLog -List | | |
Select-Object -ExpandProperty Log | | |
foreach { | |
Get-EventLog -LogName $_ -After "01-24-2014 06:00:00" -Before "01-24-2014 07:00:00" | |
} |
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
$test = Get-Content .\test.txt | |
$output = $test[0..($test.count - 2)] |
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
$var[0..($var.count - 2)] |
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
$var[1..($var.count - 1)] |
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
$printserver = "\\\\PrintServer-01\\" | |
$printers = Get-WmiObject Win32_Printer -Filter "Name LIKE '%$($printserver)%'" | |
foreach ($printer in $printers) { | |
$printer.PSBase.Delete() | |
} |
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
$folder = "\\server\share" | |
$tempfile = "c:\temp\output.csv" | |
$items = Get-ChildItem $folder -Recurse -ErrorAction SilentlyContinue | |
foreach ($item in $items) { | |
try { | |
$obj_acl = get-acl $item.FullName -ErrorAction Stop | |
$acls = $obj_acl.access | where {($_.isinherited -eq $false) -and (($_.identityreference -like "Domain1\*") -or ($_.identityreference -like "Domain2\*"))} |
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
$vms = Get-VM | |
$output = foreach ($vm in $vms) { | |
foreach ($adapter in $vm.NetworkAdapters) { | |
$props = @{'Name' = $vm.Name; | |
'Type' = $adapter.Type} | |
$obj = New-Object -TypeName PSObject -Property $props | |
Write-Output $obj | |
} |
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
$Setup = 'HKLM:\SOFTWARE\Microsoft\Internet Explorer\Setup' | |
$Main = 'HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main' | |
$Versions = '9', '10', '11' | |
#Disable upgrading to Versions listed above | |
try { Get-Item -Path $Setup -ErrorAction Stop } | |
catch { New-Item -Path $Setup } | |
foreach ($ver in $Versions) { | |
if ([int]$ver -lt 10) { $dna = $ver + '0' } |
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
$BirthDay = Get-Date "8-16-1989 17:55" | |
$BirthDay.AddSeconds(1000000000) |
OlderNewer