├── .DS_Store ├── Add-LocalAdmin.ps1 ├── Add-Zip.ps1 ├── AlphaFS.dll ├── CSVFileView.exe ├── CSVed.exe ├── Check-Flags.ps1 ├── Check-Header.ps1 ├── ConvertFrom-Bytes.ps1 ├── ConvertTo-Bytes.ps1 ├── Copy-File.ps1 ├── CopyTo-Image.ps1 ├── Create Azure App Registration for use With MS Graph.ps1 ├── Create-DesktopPin.ps1 ├── Create-DummyFile.ps1 ├── Create-LocalUser.ps1 ├── Create-Shortcut.ps1 ├── Create-ThisPcPin.ps1 ├── DailyStatsReport.ps1 ├── Decode-Text.ps1 ├── DelTempFiles.ps1 ├── Delete_Days_Back.ps1 ├── Desktop_Management.ps1 ├── DiskSpaceGUITool.ps1 ├── Disk_Errors.ps1 ├── EWSManagedAPI2.2.msi ├── Enable-PSRemoting.ps1 ├── Encode-Text.ps1 ├── Expand-OU.ps1 ├── Expand-ZIPFile.ps1 ├── Fix-Spaces.ps1 ├── ForceInstallUpdatesRemote.ps1 ├── Get-BitLockerInfo.ps1 ├── Get-BitLockerKey.ps1 ├── Get-BootConfigurationData.ps1 ├── Get-ChromeExtension.ps1 ├── Get-Clipboard.ps1 ├── Get-ComputerShares.ps1 ├── Get-FailingDrive.ps1 ├── Get-FileSizeOnDisk.ps1 ├── Get-Files.ps1 ├── Get-Files.ps1 (Robocopy only version) ├── Get-Firewall.ps1 ├── Get-FolderACL.ps1 ├── Get-FolderAccess.ps1 ├── Get-FolderSize.ps1 ├── Get-Header.ps1 ├── Get-IEVersion.ps1 ├── Get-InstalledApps.ps1 ├── Get-Lines.ps1 ├── Get-LocalAdmin.ps1 ├── Get-LoggedOnUser.ps1 ├── Get-LogonHistory.ps1 ├── Get-LogonStatus.ps1 ├── Get-MAC.ps1 ├── Get-MailboxContacts.ps1 ├── Get-MailboxStats.ps1 ├── Get-MappedDrives.ps1 ├── Get-Monitor.ps1 ├── Get-MyADObject.ps1 ├── Get-NetworkShortcut.ps1 ├── Get-OfficeVersion.ps1 ├── Get-ParameterAliases.ps1 ├── Get-PdfText.ps1 ├── Get-Powercfg.ps1 ├── Get-PrinterClients.ps1 ├── Get-PrinterHosts.ps1 ├── Get-ProductKey.ps1 ├── Get-ProxyAddresses.ps1 ├── Get-SKU.ps1 ├── Get-SNMPData.ps1 ├── Get-SNMPPrinterInfo.ps1 ├── Get-ShaHash.ps1 ├── Get-ShortPath.ps1 ├── Get-Shortcut.ps1 ├── Get-User.ps1 ├── GithubRestApi.ps1 ├── Greenshot.exe ├── How_to_Make_a_PowerShell_Script_Wait_for_a_Specific_Condition.ps1 ├── Import-MailboxContacts.ps1 ├── LICENSE ├── Logoff-User.ps1 ├── MTFv2.ps1 ├── New-NetworkShortcut.ps1 ├── Out-Menu.ps1 ├── PRobocopy.ps1 ├── Pulseway_Desktop_Icon.ps1 ├── README.md ├── Reboot.ps1 ├── Remote-Registry.ps1 ├── Remove-LocalAdmin.ps1 ├── Remove-NetworkShortcut.ps1 ├── SQL_Backup.ps1 ├── Save-CSVasExcel.ps1 ├── Save-ExcelasCSV.ps1 ├── Search-BoardGameGeek.ps1 ├── Send-Telegram.ps1 ├── Set-Clipboard.ps1 ├── Set-Wallpaper.ps1 ├── SetDNS.ps1 ├── Setup-Network.ps1 ├── Show-WifiPasswords.ps1 ├── Software_Inventory.ps1 ├── Split-Join-Files.ps1 ├── Store-Creds.ps1 ├── SystemInformation.ps1 ├── Take-Ownership.ps1 ├── Test-Port.ps1 ├── Test-RPC.ps1 ├── Twelve_Tools.ps1 ├── Write-Object.ps1 ├── Write-Progress Example.ps1 ├── add-import-export-wifi.ps1 ├── beep songs.ps1 ├── chromeapp.ps1 ├── cht file editor.ps1 ├── convert file to bits.ps1 ├── copy files keep structure.ps1 ├── create_win_admin.ps1 ├── diskfree.ps1 ├── faster array vs arraylist.ps1 ├── faster gci vs robocopy.ps1 ├── faster string vs stringbuilder.ps1 ├── fastest event log.ps1 ├── fastest foreach.ps1 ├── fastest null.ps1 ├── fastest where.ps1 ├── fix_file_path_too_long_subst.ps1 ├── fix_file_path_too_long_subst_v2.ps1 ├── install fonts v2.ps1 ├── install fonts.ps1 ├── menu go back example.ps1 ├── notnull.ps1 ├── ping1.ps1 ├── pingt.ps1 ├── profile.ps1 ├── propmatch.ps1 ├── reddit powershell questions.ps1 ├── set wallpaper from reddit.ps1 ├── sortprop.ps1 ├── split csv into multiple files.ps1 ├── strikethrough.ps1 ├── subinacl.exe ├── system-uptime.ps1 ├── touch.ps1 ├── upsidedown.ps1 └── youtube-dl.ps1 /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gangstanthony/PowerShell/df7e9de1bfc0149f6b900ec65679516c5ed7503a/.DS_Store -------------------------------------------------------------------------------- /Add-LocalAdmin.ps1: -------------------------------------------------------------------------------- 1 | function Add-LocalAdmin { 2 | param ( 3 | [string]$comp, 4 | [string]$sam, 5 | [string]$domain = $env:USERDOMAIN 6 | ) 7 | 8 | if ($comp -match '^\s*$') { 9 | throw "Comp not found '$comp'" 10 | } 11 | 12 | if ($sam -match '^\s*$') { 13 | throw "Sam not acceptable '$sam'" 14 | } 15 | 16 | ([adsi]"WinNT://$comp/Administrators").add("WinNT://$domain/$sam") 17 | } 18 | -------------------------------------------------------------------------------- /Add-Zip.ps1: -------------------------------------------------------------------------------- 1 | # http://stackoverflow.com/questions/11021879/creating-a-zipped-compressed-folder-in-windows-using-powershell-or-the-command-l 2 | 3 | # when using in foreach, must sleep -m 500 after every file 4 | 5 | # on conflict, popup will ask to copy and replace 6 | 7 | function Add-Zip { 8 | param ( 9 | [string]$sourceFile, 10 | [string]$zipFile 11 | ) 12 | 13 | begin { 14 | function Resolve-FullPath ([string]$Path) { 15 | if ( -not ([System.IO.Path]::IsPathRooted($Path)) ) { 16 | # $Path = Join-Path (Get-Location) $Path 17 | $Path = "$PWD\$Path" 18 | } 19 | [IO.Path]::GetFullPath($Path) 20 | } 21 | } 22 | 23 | process { 24 | $sourceFile = Resolve-FullPath $sourceFile 25 | $zipFile = Resolve-FullPath $zipFile 26 | 27 | if (-not (Test-Path $zipFile)) { 28 | Set-Content $zipFile ('PK' + [char]5 + [char]6 + ([string][char]0 * 18)) 29 | (Get-Item $zipFile).IsReadOnly = $false 30 | } 31 | 32 | $shell = New-Object -ComObject shell.application 33 | $zipPackage = $shell.NameSpace($zipFile) 34 | 35 | $zipPackage.CopyHere($sourceFile) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /AlphaFS.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gangstanthony/PowerShell/df7e9de1bfc0149f6b900ec65679516c5ed7503a/AlphaFS.dll -------------------------------------------------------------------------------- /CSVFileView.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gangstanthony/PowerShell/df7e9de1bfc0149f6b900ec65679516c5ed7503a/CSVFileView.exe -------------------------------------------------------------------------------- /CSVed.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gangstanthony/PowerShell/df7e9de1bfc0149f6b900ec65679516c5ed7503a/CSVed.exe -------------------------------------------------------------------------------- /Check-Flags.ps1: -------------------------------------------------------------------------------- 1 | # https://knowledge.zomers.eu/PowerShell/Pages/How-to-control-UserAccountControl-Active-Directory-flags-with-PowerShell.aspx 2 | # https://jackstromberg.com/2013/01/useraccountcontrol-attributeflag-values/ 3 | # https://www.reddit.com/r/PowerShell/comments/aldehr/getaduser_filter_not_working/ 4 | 5 | function Check-Flags ($sam = $env:USERNAME) { 6 | $uac = [int](([adsisearcher]"samaccountname=$sam").FindOne().Properties.useraccountcontrol | Out-String).Trim() 7 | 8 | if ($uac -eq 0) { 9 | throw 'UAC is 0' 10 | } 11 | 12 | $flags = @{ 13 | SCRIPT = 1 14 | ACCOUNTDISABLE = 2 15 | HOMEDIR_REQUIRED = 8 16 | LOCKOUT = 16 17 | PASSWD_NOTREQD = 32 18 | # Note You cannot assign this permission by directly modifying the UserAccountControl attribute. For information about how to set the permission programmatically, see the "Property flag descriptions" section. 19 | PASSWD_CANT_CHANGE = 64 20 | ENCRYPTED_TEXT_PWD_ALLOWED = 128 21 | TEMP_DUPLICATE_ACCOUNT = 256 22 | NORMAL_ACCOUNT = 512 23 | INTERDOMAIN_TRUST_ACCOUNT = 2048 24 | WORKSTATION_TRUST_ACCOUNT = 4096 25 | SERVER_TRUST_ACCOUNT = 8192 26 | DONT_EXPIRE_PASSWORD = 65536 27 | MNS_LOGON_ACCOUNT = 131072 28 | SMARTCARD_REQUIRED = 262144 29 | TRUSTED_FOR_DELEGATION = 524288 30 | NOT_DELEGATED = 1048576 31 | USE_DES_KEY_ONLY = 2097152 32 | DONT_REQ_PREAUTH = 4194304 33 | PASSWORD_EXPIRED = 8388608 34 | TRUSTED_TO_AUTH_FOR_DELEGATION = 16777216 35 | PARTIAL_SECRETS_ACCOUNT = 67108864 36 | } 37 | 38 | $hash = New-Object System.Collections.Specialized.OrderedDictionary 39 | $hash.Add('SAM', $sam) 40 | $hash.Add('UAC', $uac) 41 | 42 | foreach ($key in $flags.Keys) { 43 | if (($uac -band $flags[$key]) -ne 0) { 44 | $hash.Add($key, $true) 45 | } else { 46 | $hash.Add($key, $false) 47 | } 48 | } 49 | 50 | New-Object psobject -Property $hash 51 | } 52 | 53 | # check-flags -sam user1 54 | # SAM : user1 55 | # UAC : 66048 56 | # INTERDOMAIN_TRUST_ACCOUNT : False 57 | # SERVER_TRUST_ACCOUNT : False 58 | # PASSWD_CANT_CHANGE : False 59 | # NORMAL_ACCOUNT : True 60 | # TEMP_DUPLICATE_ACCOUNT : False 61 | # HOMEDIR_REQUIRED : False 62 | # ENCRYPTED_TEXT_PWD_ALLOWED : False 63 | # PARTIAL_SECRETS_ACCOUNT : False 64 | # TRUSTED_FOR_DELEGATION : False 65 | # DONT_EXPIRE_PASSWORD : True 66 | # NOT_DELEGATED : False 67 | # WORKSTATION_TRUST_ACCOUNT : False 68 | # PASSWD_NOTREQD : False 69 | # USE_DES_KEY_ONLY : False 70 | # PASSWORD_EXPIRED : False 71 | # TRUSTED_TO_AUTH_FOR_DELEGATION : False 72 | # MNS_LOGON_ACCOUNT : False 73 | # DONT_REQ_PREAUTH : False 74 | # LOCKOUT : False 75 | # SCRIPT : False 76 | # SMARTCARD_REQUIRED : False 77 | # ACCOUNTDISABLE : False 78 | -------------------------------------------------------------------------------- /Check-Header.ps1: -------------------------------------------------------------------------------- 1 | # http://learningpcs.blogspot.com/2012/07/powershell-v3-check-file-headers.html 2 | # https://en.wikipedia.org/wiki/List_of_file_signatures 3 | # http://www.garykessler.net/library/file_sigs.html 4 | 5 | function Check-Header { 6 | param ( 7 | $path 8 | ) 9 | 10 | $path = Resolve-FullPath $path 11 | 12 | # Hexidecimal signatures for expected files 13 | $known = @' 14 | "Extension","Header" 15 | "3gp","66 74 79 70 33 67" 16 | "7z","37 7A BC AF 27 1C" 17 | "8sv","38 53 56 58" 18 | "8svx","46 4F 52 4D nn nn nn nn" 19 | "acbm","46 4F 52 4D nn nn nn nn" 20 | "aif","41 49 46 46" 21 | "aiff","46 4F 52 4D nn nn nn nn" 22 | "anbm","46 4F 52 4D nn nn nn nn" 23 | "anim","46 4F 52 4D nn nn nn nn " 24 | "asf","30 26 B2 75 8E 66 CF 11" 25 | "avi","52 49 46 46 nn nn nn nn " 26 | "bac","42 41 43 4B 4D 49 4B 45" 27 | "bpg","42 50 47 FB" 28 | "cab","4D 53 43 46" 29 | "cin","80 2A 5F D7" 30 | "class","CA FE BA BE" 31 | "cmus","46 4F 52 4D nn nn nn nn" 32 | "cr2","49 49 2A 00 10 00 00 00" 33 | "crx","43 72 32 34" 34 | "cwk","05 07 00 00 42 4F 42 4F" 35 | "cwk","06 07 E1 00 42 4F 42 4F" 36 | "dat","50 4D 4F 43 43 4D 4F 43" 37 | "DBA","BE BA FE CA" 38 | "DBA","00 01 42 44" 39 | "dex","64 65 78 0A 30 33 35 00" 40 | "djvu","41 54 26 54 46 4F 52 4D nn nn nn nn 44 4A 56" 41 | "dmg","78 01 73 0D 62 62 60" 42 | "doc","D0 CF 11 E0 A1 B1 1A E1" 43 | "dpx","53 44 50 58" 44 | "exr","76 2F 31 01" 45 | "fax","46 41 58 58" 46 | "faxx","46 4F 52 4D nn nn nn nn" 47 | "fh8","41 47 44 33" 48 | "fits","53 49 4D 50 4C 45 20 20" 49 | "flac","66 4C 61 43" 50 | "flif","46 4C 49 46" 51 | "ftxt","46 4F 52 4D nn nn nn nn" 52 | "gif","47 49 46 38 37 61" 53 | "ico","00 00 01 00" 54 | "idx","49 4E 44 58" 55 | "iff","41 43 42 4D" 56 | "iff","41 4E 42 4D" 57 | "iff","41 4E 49 4D" 58 | "iff","46 4F 52 4D nn nn nn nn" 59 | "ilbm","46 4F 52 4D nn nn nn nn" 60 | "iso","43 44 30 30 31" 61 | "jpg","FF D8 FF DB" 62 | "lbm","49 4C 42 4D" 63 | "lz","4C 5A 49 50" 64 | "lz4","04 22 4D 18" 65 | "mid","4D 54 68 64" 66 | "mkv","1A 45 DF A3" 67 | "MLV","4D 4C 56 49" 68 | "mus","43 4D 55 53" 69 | "nes","4E 45 53 1A" 70 | "ods","50 4B 05 06" 71 | "ogg","4F 67 67 53" 72 | "PDB","00 00 00 00 00 00 00 00" 73 | "pdf","25 50 44 46" 74 | "png","89 50 4E 47 0D 0A 1A 0A" 75 | "ps","25 21 50 53" 76 | "psd","38 42 50 53" 77 | "rar","52 61 72 21 1A 07 00" 78 | "rar","52 61 72 21 1A 07 01 00" 79 | "smu","53 4D 55 53" 80 | "smus","46 4F 52 4D nn nn nn nn" 81 | "stg","4D 49 4C 20" 82 | "tar","75 73 74 61 72 00 30 30" 83 | "TDA","00 01 44 54" 84 | "tif","49 49 2A 00" 85 | "toast","45 52 02 00 00 00" 86 | "tox","74 6F 78 33" 87 | "txt","46 54 58 54" 88 | "vsdx","50 4B 07 08" 89 | "wav","52 49 46 46 nn nn nn nn" 90 | "wma","A6 D9 00 AA 00 62 CE 6C" 91 | "xar","78 61 72 21" 92 | "yuv","59 55 56 4E" 93 | "yuvn","46 4F 52 4D nn nn nn nn" 94 | "zip","50 4B 03 04" 95 | "epub","50 4B 03 04 0A 00 02 00" 96 | '@ | ConvertFrom-Csv | sort {$_.header.length} -Descending 97 | 98 | $known | % {$_.header = $_.header -replace '\s'} 99 | 100 | try { 101 | # Get content of each file (up to 4 bytes) for analysis 102 | $HeaderAsHexString = New-Object System.Text.StringBuilder 103 | [Byte[]](Get-Content -Path $path -TotalCount 4 -Encoding Byte -ea Stop) | % { 104 | if (("{0:X}" -f $_).length -eq 1) { 105 | $null = $HeaderAsHexString.Append('0{0:X}' -f $_) 106 | } else { 107 | $null = $HeaderAsHexString.Append('{0:X}' -f $_) 108 | } 109 | } 110 | 111 | # Validate file header 112 | # might change .startswith() to -match. 113 | # might remove 'select -f 1' to get all possible matching extensions, or just somehow make it a better match. 114 | $known | ? {$_.header.startswith($HeaderAsHexString.ToString())} | select -f 1 | % {$_.extension} 115 | } catch {} 116 | } 117 | -------------------------------------------------------------------------------- /ConvertFrom-Bytes.ps1: -------------------------------------------------------------------------------- 1 | function ConvertFrom-Bytes { 2 | param ( 3 | [string]$bytes, 4 | [string]$savepath 5 | ) 6 | 7 | $dir = Split-Path $savepath 8 | if (!(Test-Path $dir)) { 9 | md $dir | Out-Null 10 | } 11 | 12 | [convert]::FromBase64String($bytes) | Set-Content $savepath -Encoding Byte 13 | } 14 | -------------------------------------------------------------------------------- /ConvertTo-Bytes.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-Bytes { 2 | param ( 3 | [string]$file 4 | ) 5 | 6 | if (!$file -or !(Test-Path $file)) { 7 | throw "file not found: '$file'" 8 | } 9 | 10 | [convert]::ToBase64String((Get-Content $file -Encoding Byte)) 11 | } 12 | -------------------------------------------------------------------------------- /CopyTo-Image.ps1: -------------------------------------------------------------------------------- 1 | # http://www.online-tech-tips.com/computer-tips/hide-file-in-picture/ 2 | # recommend using png instead of jpg 3 | 4 | function CopyTo-Image { 5 | param ( 6 | [string]$file, 7 | [string]$image 8 | ) 9 | 10 | $date = date -f yyyyMMddHHmmss 11 | 12 | $fileext = $file.split('.')[-1] 13 | 14 | if ($fileext -eq 'zip') { 15 | $zip = $file 16 | } else { 17 | $zip = "c:\temp\$date.zip" 18 | Compress-Archive $file $zip 19 | } 20 | 21 | $path = Split-Path $image 22 | $imageext = $image.split('.')[-1] 23 | $newname = (Split-Path $file -Leaf).Split('.')[0] + '.' + $imageext 24 | $newpath = Join-Path $path $newname 25 | 26 | cmd "/c copy /b $image + $zip `"$newpath`"" 27 | 28 | if ($fileext -ne 'zip') { 29 | del "c:\temp\$date.zip" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Create-DesktopPin.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .example 3 | Create-DesktopPin -name "google drive" -path "c:\users\name\google drive" 4 | 5 | .example 6 | Create-DesktopPin -name "google drive" -delete # -force 7 | #> 8 | 9 | function Create-DesktopPin { 10 | param ( 11 | $name, 12 | $path, 13 | [switch]$delete, 14 | [switch]$force 15 | ) 16 | 17 | if ($delete) { 18 | $item = dir "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\" | ? {(Get-ItemProperty $_.pspath).'(default)' -ceq $name} 19 | $guid = (Split-Path $item.name -Leaf).trim('{}') 20 | if (!$guid) { 21 | throw "Could not find: $name" 22 | } else { 23 | if (!$force) { 24 | $createdby = (Get-ItemProperty $item.PSPath).CreatedBy 25 | if ($createdby -ne 'Create-DesktopPin') { 26 | $answer = Read-Host 'Looks like this Pin was not created by Create-DesktopPin. Delete anyway? y/[N]' 27 | if ($answer -ne 'y') { 28 | return 29 | } 30 | } 31 | } 32 | } 33 | 34 | $null = reg delete "HKCU\Software\Classes\CLSID\{$guid}" /f 35 | $null = reg delete "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}" /f 36 | $null = reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{$guid}" /f 37 | $null = reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "{$guid}" /f 38 | } else { 39 | if (!(New-Object Security.Principal.WindowsPrincipal ([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) { 40 | throw 'you are not admin' 41 | } 42 | 43 | [String] $GUID = [guid]::NewGuid().ToString() 44 | $guid 45 | 46 | $null = reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "{$guid}" /t REG_DWORD /d "1" /f 47 | $null = reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{$guid}" /ve /t REG_SZ /d $name /f 48 | $null = reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{$guid}" /v "CreatedBy" /t REG_SZ /d "Create-DesktopPin" /f 49 | 50 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}" /ve /t REG_SZ /d $name /f 51 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}" /v "System.IsPinnedToNamespaceTree" /t REG_DWORD /d "1" /f 52 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}" /v "SortOrderIndex" /t REG_DWORD /d "66" /f 53 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}\InProcServer32" /ve /t REG_EXPAND_SZ /d "%%SYSTEMROOT%%\system32\shell32.dll" /f 54 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}\ShellFolder" /v "FolderValueFlags" /t REG_DWORD /d "40" /f 55 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}\ShellFolder" /v "Attributes" /t REG_DWORD /d "4034920525" /f 56 | #$null = reg add "HKCU\Software\Classes\CLSID\{$guid}\DefaultIcon" /ve /t REG_SZ /d "C:\Program Files (x86)\Google\Drive\googledrivesync.exe,0" /f 57 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}\DefaultIcon" /ve /t REG_SZ /d "%%SystemRoot%%\System32\shell32.dll,3" /f 58 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}\Instance" /v "CLSID" /t REG_SZ /d "{0E5AAE11-A475-4c5b-AB00-C66DE400274E}" /f 59 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}\Instance\InitPropertyBag" /v "Attributes" /t REG_DWORD /d "17" /f 60 | $null = reg add "HKCU\Software\Classes\CLSID\{$guid}\Instance\InitPropertyBag" /v "TargetFolderPath" /t REG_SZ /d $path /f 61 | 62 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}" /ve /t REG_SZ /d $name /f 63 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}" /v "System.IsPinnedToNamespaceTree" /t REG_DWORD /d "1" /f 64 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}" /v "SortOrderIndex" /t REG_DWORD /d "66" /f 65 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}\InProcServer32" /ve /t REG_EXPAND_SZ /d "%%SYSTEMROOT%%\system32\shell32.dll" /f 66 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}\ShellFolder" /v "FolderValueFlags" /t REG_DWORD /d "40" /f 67 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}\ShellFolder" /v "Attributes" /t REG_DWORD /d "4034920525" /f 68 | #$null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}\DefaultIcon" /ve /t REG_SZ /d "C:\Program Files (x86)\Google\Drive\googledrivesync.exe,0" /f 69 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}\DefaultIcon" /ve /t REG_SZ /d "%%SystemRoot%%\System32\shell32.dll,3" /f 70 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}\Instance" /v "CLSID" /t REG_SZ /d "{0E5AAE11-A475-4c5b-AB00-C66DE400274E}" /f 71 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}\Instance\InitPropertyBag" /v "Attributes" /t REG_DWORD /d "17" /f 72 | $null = reg add "HKCU\Software\Classes\Wow6432Node\CLSID\{$guid}\Instance\InitPropertyBag" /v "TargetFolderPath" /t REG_SZ /d $path /f 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Create-DummyFile.ps1: -------------------------------------------------------------------------------- 1 | # https://www.tutorialspoint.com/how-to-create-a-dummy-file-of-any-size-with-powershell 2 | 3 | function Create-DummyFile { 4 | param ( 5 | $path = 'c:\temp', 6 | $size = 15mb 7 | ) 8 | 9 | $f = new-object System.IO.FileStream $path, Create, ReadWrite 10 | $f.SetLength($size) 11 | $f.Close() 12 | } 13 | -------------------------------------------------------------------------------- /Create-LocalUser.ps1: -------------------------------------------------------------------------------- 1 | 2 | # http://www.selfadsi.org/ads-attributes/user-userAccountControl.htm 3 | 4 | function Create-LocalUser { 5 | param ( 6 | [string]$computer = $env:computername, 7 | [string]$fullname, 8 | [string]$username, 9 | [string]$password, 10 | [switch]$passworddoesnotexpire, 11 | [string]$addtogroup = 'Administrators', 12 | [switch]$CheckFirst = $true 13 | ) 14 | 15 | if (!$username -or !$password) { 16 | throw 'no username or password' 17 | } 18 | 19 | if ($checkfirst -and ([ADSI]"WinNT://$computer/$username").Name) { 20 | Write-Warning "$username already exists on $computer" 21 | return 22 | } 23 | 24 | $objOU = [ADSI]"WinNT://$computer" 25 | $objUser = $objOU.Create('user', $username) 26 | $objUser.SetPassword($password) 27 | $objUser.SetInfo() 28 | $objUser.FullName = $fullname 29 | $objUser.SetInfo() 30 | #$objUser.Description = 'Test user' 31 | #$objUser.SetInfo() 32 | 33 | if ($passworddoesnotexpire) { 34 | $objUser.UserFlags = 65536 # password does not expire 35 | $objUser.SetInfo() 36 | } 37 | 38 | if ($addtogroup) { 39 | ([ADSI]"WinNT://$computer/$addtogroup").Add("WinNT://$computer/$username") 40 | } 41 | } 42 | 43 | # Create-LocalUser -computer $env:COMPUTERNAME -fullname 'Test' -username 'test' -password 'Password1' -passworddoesnotexpire -addtogroup 'Administrators' 44 | -------------------------------------------------------------------------------- /Create-Shortcut.ps1: -------------------------------------------------------------------------------- 1 | # https://www.reddit.com/r/PowerShell/comments/7xa4sk/programmatically_create_shortcuts_w_run_as_admin/du6pro0/ 2 | 3 | # Create-Shortcut 4 | # 5 | # Create-Shortcut -Source C:\temp\test.txt -DestinationLnk C:\temp\test.txt.lnk 6 | # 7 | # Arguments 8 | # Description 9 | # FullName 10 | # Hotkey 11 | # IconLocation = '%SystemRoot%\system32\SHELL32.dll,16' # printer 12 | # RelativePath 13 | # TargetPath 14 | # WindowStyle 15 | # WorkingDirectory 16 | 17 | function Create-Shortcut { 18 | param ( 19 | [string]$Source, 20 | [string]$DestinationLnk, 21 | [string]$Arguments 22 | ) 23 | 24 | begin { 25 | $WshShell = New-Object -ComObject WScript.Shell 26 | } 27 | 28 | process { 29 | if (!$Source) {Throw 'No Source'} 30 | if (!$DestinationLnk) {Throw 'No DestinationLnk'} 31 | 32 | $Shortcut = $WshShell.CreateShortcut($DestinationLnk) 33 | $Shortcut.TargetPath = $Source 34 | if ($Arguments) { 35 | $Shortcut.Arguments = $Arguments 36 | } 37 | $Shortcut.Save() 38 | } 39 | 40 | end { 41 | function Release-Ref ($ref) { 42 | ([System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$ref) -gt 0) 43 | [System.GC]::Collect() 44 | [System.GC]::WaitForPendingFinalizers() 45 | } 46 | $Shortcut, $WshShell | % {$null = Release-Ref $_} 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Decode-Text.ps1: -------------------------------------------------------------------------------- 1 | # http://www.powershelladmin.com/wiki/Powershell_prompt_for_password_convert_securestring_to_plain_text 2 | 3 | function Decode-Text { 4 | param ( 5 | [string]$Text, 6 | [validateset('SecureString', 'SecureStringWithKey', 'Base64', 'ASCII')] 7 | [string]$Method = 'Base64' 8 | ) 9 | 10 | process { 11 | if (!$Text) { 12 | $Text = $input 13 | } 14 | } 15 | 16 | end { 17 | switch ($method) { 18 | 'SecureString' { 19 | (New-Object pscredential ' ', (ConvertTo-SecureString $text)).GetNetworkCredential().Password 20 | #$marshal = [Runtime.InteropServices.Marshal] 21 | #$marshal::PtrToStringAuto( $marshal::SecureStringToBSTR(($text | convertto-securestring)) ) 22 | } 23 | 24 | 'SecureStringWithKey' { 25 | (New-Object pscredential ' ', (ConvertTo-SecureString $text -Key (1..16))).GetNetworkCredential().Password 26 | } 27 | 28 | 'Base64' { 29 | [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($text)) 30 | } 31 | 32 | 'ASCII' { 33 | $pwlength = $text.Length / 3 - 1 34 | -join(0..$pwlength | % {[char](32 + $text.Substring(($_*3), 3))}) 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /DelTempFiles.ps1: -------------------------------------------------------------------------------- 1 | $folders = @('C:\Windows\Temp\*', 'C:\Documents and Settings\*\Local Settings\temp\*', 'C:\Users\*\Appdata\Local\Temp\*', 'C:\Users\*\Appdata\Local\Microsoft\Windows\Temporary Internet Files\*', 'C:\Windows\SoftwareDistribution\Download', 'C:\Windows\System32\FNTCACHE.DAT') 2 | foreach ($folder in $folders) {Remove-Item $folder -force -recurse} -------------------------------------------------------------------------------- /Delete_Days_Back.ps1: -------------------------------------------------------------------------------- 1 | ## Variables 2 | $Dest = "C:\Support\SQLBac\"; # Backup path on server (optional). 3 | $Daysback = "0"; # Days to keep. 4 | 5 | $CurrentDate = Get-Date 6 | $DatetoDelete = $CurrentDate.AddDays($Daysback) 7 | Get-ChildItem $Dest | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item -------------------------------------------------------------------------------- /Desktop_Management.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | ============================================================================== 3 | DESKTOP MANAGEMENT 4 | ============================================================================== 5 | Created: [07/24/2014] 6 | Author: Ethan Bell 7 | Arguments: N/A 8 | ============================================================================== 9 | Modified: 10 | Modifications: 11 | ============================================================================== 12 | Purpose: Shortcuts for the Desktop 13 | Options: Desktop, Drives, Control Panel, Favorites, Printers, History, Recent 14 | Network Connections, Program Files, Local Apps, Start-up Folder 15 | ============================================================================== 16 | #> 17 | 18 | 19 | $ShellApp = new-Object -ComObject shell.application 20 | Add-Type -AssemblyName PresentationFramework 21 | #$ShellApp.Explore(0x21) 22 | 23 | 24 | [xml]$xaml = @" 25 | 26 | 30 | 31 |