Skip to content

Instantly share code, notes, and snippets.

@Santaro255
Santaro255 / ESDtoWIM.ps1
Created January 10, 2019 08:50
Convert ESD file to WIM. Enter ESD filename then choose index(which version do you need) after this enter output WIM filename and wait. Filenames must contain extensions.
<#
This script convert ESD to WIM file, should run with administrative rights.
There is no error catcher so if you wrong in path or filename restart script with Ctrl+C or close window.
#>
$esdfile=Read-Host -Prompt "Enter ESD filename with extension(if in this folder) or path"
Write-Host "`nDistributive contains:"
Dism.exe /Get-WimInfo /WimFile:$esdfile
@Santaro255
Santaro255 / my_comp_icon.ps1
Created January 10, 2019 09:12
Enable "My Computer" icon with powershell script. After running script desktop should be updated by pressing F5.
#HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel\ {20D04FE0-3AEA-1069-A2D8-08002B30309D} = 0/show , 1/hide
$path="HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
$name="{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$exist="Get-ItemProperty -Path $path -Name $name"
if ($exist)
{
Set-ItemProperty -Path $path -Name $name -Value 0
}
Else
{
@Santaro255
Santaro255 / replace_words.py
Created January 10, 2019 13:25
Sample how to replace words in text by using comparing with array in Python.
#import regular expression
import re
#text
message = "Sample text here. Some kind of message. More: complex@ !text? :message;."
#split text by words
splitmsg = re.findall('\w+',message)
#array of words that should be replaced
words = {'text':"t**t",'message':"msg"}
#print original text
print(message)
@Santaro255
Santaro255 / SCCM_User_Device_and_Info.ps1
Last active January 14, 2019 14:59
This script get PC names for user from SCCM WMI namespace show list then verify logged users from that list show it and plus show user info from AD (DisplayName, Department, Title, Office, telephoneNumber, MobilePhone, Enabled, LastLogonDate, PasswordLastSet).
#define SCCM server
$srvsccm = "SERVERNAME"
#input username
$username = Read-Host "Input username (at least 3 letters):"
#get users pc from sccm wmi namespace
$userpc = Get-WmiObject -ComputerName $srvsccm -Namespace "root\SMS\Site_NVK" -Class SMS_UserMachineRelationship -Filter "UniqueUserName LIKE '%$username%'" | Format-Table -Property UniqueUserName, ResourceName, IsActive -AutoSize
#get only pc names
$userpcname = (Get-WmiObject -ComputerName $srvsccm -Namespace "root\SMS\Site_NVK" -Class SMS_UserMachineRelationship -Filter "UniqueUserName LIKE '%$username%'").ResourceName
#get user info from AD (need RSAT or powershell AD module)
$userinfo = Get-ADUser -Filter "SamAccountName -like '*$username*'" -Properties DisplayName, Department, Title, Office, telephoneNumber, MobilePhone, Enabled, LastLogonDate, PasswordLastSet | select DisplayName, Department, Title, Office, telephoneNumber, MobilePhone, Enabled, LastLogonDate, PasswordLastSet
#define scan account
$domain = "DOMAIN"
$name = "NAME"
$scandef = "DOMAIN\NAME"
#get username
$getusername = (Get-WmiObject -Class Win32_ComputerSystem).Username
function scanacl() {
#set full access for scan
$access=New-Object System.Security.AccessControl.FileSystemAccessRule ("$scandef","FullControl","ContainerInherit,ObjectInherit","None","Allow")
$ACL = Get-Acl -Path C:\Scan
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms723602(v%3dvs.85)
txt = "test"
(New-Object -ComObject "SAPI.spVoice").Speak("$txt")
@Santaro255
Santaro255 / query_hp_printer_ports.ps1
Last active January 31, 2019 07:14
get hostname and ip address for HP Standard TCP\IP Port
$pcname = Read-Host "Enter PC name"
#function
function queryports() {
#.NET class for open remote registry
$registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", "$pcname")
#path
$registryKey = "SYSTEM\CurrentControlSet\Control\Print\Monitors\HP Standard TCP/IP Port\Ports"
#open registry
$regKey = $registry.OpenSubKey($registryKey)
#for counter
@Santaro255
Santaro255 / take_screenshot.ps1
Last active May 28, 2024 18:30
multiple monitors
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
#[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.SystemParameters")
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen
$w = $bounds.bounds.width#[System.Windows.SystemParameters]::VirtualScreenWidth
$h = $bounds.bounds.height#[System.Windows.SystemParameters]::VirtualScreenHeight
$img = New-Object System.Drawing.Bitmap($w, $h, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
@Santaro255
Santaro255 / exchange_remote_connect.ps1
Created March 12, 2019 13:54
create\remove PSSession to Exchange server
$q=Read-Host -Prompt "connect\disconnect"
switch ($q) {
{$q -eq "connect"} {$fqdn=Read-Host -Prompt "Enter FQDN"
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://"$fqdn"/PowerShell/ -Authentication Kerberos -Credential $UserCredential
Import-PSSession $Session -DisableNameChecking}
{$q -eq "disconnect"} {Remove-PSSession $Session}
}
https://visualstudio.microsoft.com/
https://www.microsoft.com/en-us/download/details.aspx?id=30169
Install SDK
Clear AppData\Local\Microsoft\VisualStudio\!!!VERSION!!!\ComponentModelCache