This file contains hidden or 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
Powershell | |
Set-Executionpolicy -unrestricted | |
Install-Script -Name Get-WindowsAutoPilotInfo -Scope CurrentUser | |
Get-WindowsAutoPilotInfo C:\Info.csv | |
&'C:\Program Files (x86)\Internet Explorer\iexplore.exe' https://businessstore.microsoft.com |
This file contains hidden or 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-MonitorInfo { | |
[CmdletBinding()] | |
param ([string[]]$ComputerNames = $env:computername) | |
foreach ($ComputerName in $ComputerNames){ | |
try { | |
$CimSession = New-CimSession -ComputerName $ComputerName | |
} catch { | |
Write-Warning "Please make sure PSRemoting is enabled on $ComputerName" | |
Continue | |
} |
This file contains hidden or 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
$Monitors = Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorID | |
$Computer = Get-CimInstance -Class Win32_ComputerSystem | |
$Bios = Get-CimInstance -ClassName Win32_Bios | |
foreach ($Monitor in $Monitors){ | |
$PSObject = [PSCustomObject]@{ | |
ComputerName = $Computer.Name | |
ComputerType = $Computer.model | |
ComputerSerial = $Bios.SerialNumber | |
MonitorSerial = [string]::join('',$monitor.SerialNumberID.Where{$_ -ne 0}) | |
MonitorType = [string]::join('',$monitor.UserFriendlyName.Where{$_ -ne 0}) |
This file contains hidden or 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-WickedOSandDiskObject { | |
param ($ComputerName=$env:COMPUTERNAME) | |
$CimSession = New-CimSession -ComputerName $ComputerName | |
$ComputerObject = Get-CimInstance Win32_OperatingSystem -CimSession $CimSession | Select-Object *,@{n='Disks';e={Get-CimInstance Win32_LogicalDisk -CimSession $CimSession | Select-Object *,@{n='PercentageUsed';e={"{0:P}" –f $(($_.size-$_.Freespace)/$_.size)}}}} | |
$ComputerObject.psobject.TypeNames.Insert(0, "WickedOSandDiskObject") | |
$ComputerObject | |
} |
This file contains hidden or 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-Feed { | |
[CmdletBinding()] | |
param ($Feeduri = 'https://powershell.org/feed/') | |
$c = 0 | |
$Feeds = Invoke-RestMethod -uri $Feeduri | |
$FeedObjects = foreach ($Feed in $Feeds){ | |
[PSCustomObject]@{ | |
'No.' = ++$c | |
Title = $Feed.title | |
"Publication date" = $Feed.pubDate |
This file contains hidden or 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-LegacyCommandObject { | |
[CmdletBinding()] | |
param ([ValidatePattern("^(netstat|arp)")] | |
[string]$CommandLine) | |
$Result = iex $CommandLine.split(';',2)[0] | |
$Headers = $Result -match '^\w+(`n`r)*' | |
foreach ($Line in $Result) { | |
if ($Line -match '^$'){$Collect = $False;$Properties=$Null;continue} | |
if ($Headers -contains $Line){$ObjHash=@{}; if ($Line -match ':'){$Parts = $Line.split(':',2).trim();$ObjHash.add($PArts[0],$Parts[1])};$Collect = $true;$CollectParametersHeader=$true;continue} |
This file contains hidden or 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-CounterReport { | |
[CmdletBinding()] | |
param ($ComputerName=$env:COMPUTERNAME, | |
[system.io.fileinfo]$ExportCliXML, | |
[switch]$OutHTML, | |
[switch]$Quiet) | |
$OutputObject = [ordered]@{CollectionDate = $(Get-Date);ComputerName = $ComputerName} | |
$Parameters = @{ComputerName = $ComputerName} | |
Write-Verbose "Fetching Processor Time on $ComputerName" | |
$Parameters["Counter"] = "\\{0}\Processor(_Total)\% Processor Time" -f $ComputerName |
This file contains hidden or 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-UpTime { | |
[CmdletBinding()] | |
param ([parameter(ValueFromPipeline)][string]$ComputerName,[PSCredential]$Credential,$Authentication) | |
$Parameters = @{ | |
ScriptBlock = [scriptblock]::Create('if($env:OS -match "Windows"){$strBoot = $((systeminfo | find "System Boot Time") -replace "^.+:\s+|,")} else {$strBoot = (who -b) -replace "^\D+"}; Get-Date $strBoot') | |
} | |
if (!$ComputerName){$ComputerName = hostname} | |
if ($Credential){$Parameters.Add('Credential',$Credential);$Parameters.Add('ComputerName',$ComputerName)} | |
if ($Authentication){$Parameters.Add('Authentication',$Authentication)} | |
$BootDate = icm @Parameters |
This file contains hidden or 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
class ComputerInfo { | |
[string]$ComputerName | |
[string]$BIOSManufacturer | |
[string]$BIOSVersion | |
[string]$Domain | |
[int]$Processors | |
[int]$Cores | |
[int]$TotalPhysicalMemoryGB | |
[string]$OSName | |
[string]$OSArchitecture |
This file contains hidden or 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
$File = New-Item -ItemType File -Path c:\SpecialFolder\SpecialFile.txt -Force | |
$Bill = New-LocalUser "Bill Bennsson" -Password (ConvertTo-SecureString -String BillAdmin -AsPlainText -Force) | |
$Andy = New-LocalUser "Andy Pandien" -Password (ConvertTo-SecureString -String AndyUser -AsPlainText -Force) | |
$Access = [System.Security.AccessControl.FileSystemAccessRule]::new($Bill.SID,"Modify","Allow"),[System.Security.AccessControl.FileSystemAccessRule]::new($Andy.SID,"Read","Allow") | |
$NewACL=[System.Security.AccessControl.DirectorySecurity]::new() | |
$NewACL.SetSecurityDescriptorSddlForm('D:') | |
$NewACL.SetAccessRuleProtection($True, $True) | |
$Access | ForEach-Object {$NewACL.AddAccessRule($_)} | |
Set-Acl $File.FullName $NewACL |
OlderNewer