Skip to content

Instantly share code, notes, and snippets.

View pronichkin's full-sized avatar
💭
is this twitter?

Artem Pronichkin pronichkin

💭
is this twitter?
View GitHub Profile
Get-Process | Sort-Object -Unique -Property 'Name' | Select-Object -Property @(
@{
'Label' = 'Name'
'Expression' = {
$psItem.Name
}
}
@{
$String = 'Narrator.exe'
$MemoryStream = [System.IO.MemoryStream]::new()
$StreamWriter = [System.IO.StreamWriter]::new( $MemoryStream )
$StreamWriter.write( $String )
$StreamWriter.Flush()
$MemoryStream.Position = 0
$Hash = Get-FileHash -InputStream $MemoryStream -Algorithm 'SHA1'
$HexString = '0x' +
$Hash.Hash.Substring( 6, 2 ) +
Set-StrictMode -Version 'Latest'
# Collection of attributes to extract
$attributeName = [System.Collections.Generic.List[System.String]]::new()
$attributeName.Add( 'DeviceFamily' )
$attributeName.Add( 'OSVersionFull' )
$attributeName.Add( 'FlightRing' )
$attributeName.Add( 'App' )
$attributeName.Add( 'AppVer' )
<#
AnalyticsInfo class is the documented way to track OS version. It returns
a string value. The format of this string is not documented, and one should
not rely on a certain value. Those values can only be used to tell one OS
version from another.
https://docs.microsoft.com/uwp/api
/windows.system.profile.analyticsversioninfo.devicefamilyversion
This API is not available on Server Core
Function
ConvertFrom-RawXml
{
[System.Management.Automation.CmdletBindingAttribute()]
Param(
[System.Management.Automation.ParameterAttribute(
Mandatory = $True
)]
[System.String[]]
$String
function
Get-WindowsPackageEx
{
[System.Management.Automation.CmdletBindingAttribute()]
Param(
[System.Management.Automation.ParameterAttribute(
Mandatory = $True,
ParameterSetName = 'Online'
)]
@pronichkin
pronichkin / Install-NetFx3.ps1
Last active March 9, 2021 19:42
Sample for installing .NET Framework on Windows when the component is “Disabled with payload removed” (which is the default OS configuration)
$ImagePath = '<insert path to your image.iso>'
$DiskImage = Get-DiskImage -ImagePath $ImagePath
$Access = [Microsoft.PowerShell.Cmdletization.GeneratedTypes.DiskImage.Access]::ReadOnly
$DiskImage = Mount-DiskImage -InputObject $DiskImage -Access $Access -PassThru
$Volume = Get-Volume -DiskImage $DiskImage
$Path = $Volume.DriveLetter + ':'
$Source = Join-Path -Path $Path -ChildPath 'Sources\SxS'
Add-WindowsCapability -Online -Name 'NetFX3~~~~' -Source $Source
$DiskImage = Dismount-DiskImage -InputObject $DiskImage
$Session = New-Object -ComObject 'Microsoft.Update.Session'
$Searcher = $Session.CreateUpdateSearcher()
$Query = 'IsInstalled = 0 or
IsInstalled = 0 and DeploymentAction = ''OptionalInstallation'''
$Search = $Searcher.Search( $Query )
If
(
$Search.Updates.Count
@pronichkin
pronichkin / ScriptBlock-SwitchParameter.ps1
Created September 17, 2019 15:56
Shows an issue with SwitchParameter in ScriptBlock when execute remotely
[System.Management.Automation.ScriptBlock]$ScriptBlock = {
[cmdletBinding()]
Param(
[Parameter(
Mandatory = $False
)]
[ValidateNotNullOrEmpty()]