Skip to content

Instantly share code, notes, and snippets.

View martin77s's full-sized avatar

Martin Schvartzman martin77s

View GitHub Profile
@martin77s
martin77s / Get-InstalledSoftware.ps1
Created May 26, 2018 19:31
Get installed software from the local or remote machine by remotely querying the registry (NOT using Win32_Product)
function Get-InstalledSoftware {
[cmdletbinding()]
param(
[parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string[]]$ComputerName = $env:ComputerName
)
begin {
$UninstallRegKey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall'
}
@martin77s
martin77s / Get-LogonReport.ps1
Created March 21, 2018 13:50
Get-LogonReport
function Get-LogonReport {
param($ComputerName = $Env:COMPUTERNAME)
$filterXml = '<QueryList><Query Id="0" Path="Security"><Select Path="Security">*[System[(EventID=4624)]]</Select></Query></QueryList>'
$logonTypes = @{
2 = 'Interactive'
3 = 'Network'
4 = 'Batch'
5 = 'Service'
6 = 'Proxy'
@martin77s
martin77s / AddSessionConfigurationPermissions.ps1
Created February 25, 2018 17:54
Add permissions to a Session Configuration programmatically
# The identity to add permissions for
$Identity = "myDomain\nonAdmins"
# The configuration name to change permissions to (default is 'microsoft.powershell')
$sessionConfigurationName = 'microsoft.powershell'
# Get the current permissions on the default endpoint
$sddl = (Get-PSSessionConfiguration -Name $sessionConfigurationName).SecurityDescriptorSddl
@martin77s
martin77s / Add-ShareAccess.ps1
Created February 15, 2018 08:37
Add permissions to an existing share
function Add-ShareAccess {
param(
[string] $ComputerName = $env:COMPUTERNAME,
[string] $ShareName = 'Temp',
[string] $AccountName = 'Domain Users',
[ValidateSet('FullControl', 'Change','Read')] $AccessPermissions = 'Read'
)
# Convert the AccessPermissions
$accessFlags = @{
@martin77s
martin77s / Get-CertificateFromCredential.ps1
Last active February 15, 2018 08:34
Get the certificate selected in Get-Credential
function Get-CertificateFromCredential {
param([PSCredential]$Credential)
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
public static class NativeMethods {