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
| Write-Output "<?xml version=`"1.0`" encoding=`"utf-8`"?>" | |
| Write-Output "<packages>" | |
| choco list -lo -r -y | % { " <package id=`"$($_.SubString(0, $_.IndexOf("|")))`" version=`"$($_.SubString($_.IndexOf("|") + 1))`" />" } | |
| Write-Output "</packages>" |
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
| <# | |
| MODULE OF: | |
| ..One-Hundred-and-One one-liners of powershell.. | |
| Author: Chris Dek. | |
| Usage: From the powershell cmdlet run the command: | |
| Import-Module .\Hundred-OneLines.psm1 | |
| ..wait for a while to load. |
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
| # See if choco.exe is available. If not, stop execution | |
| $chocoCmd = Get-Command -Name 'choco' -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Select-Object -ExpandProperty Source | |
| if ($chocoCmd -eq $null) { break } | |
| # Settings for the scheduled task | |
| $taskAction = New-ScheduledTaskAction –Execute $chocoCmd -Argument 'upgrade all -y' | |
| $taskTrigger = New-ScheduledTaskTrigger -AtStartup | |
| $taskUserPrincipal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' | |
| $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 |
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-ENVPathFolders { | |
| <# | |
| .Synopsis Split $env:Path into an array | |
| .Notes | |
| - Handle 1) folders ending in a backslash 2) double-quoted folders 3) folders with semicolons 4) folders with spaces 5) double-semicolons I.e. blanks | |
| - Example path: 'C:\WINDOWS\;"C:\Path with semicolon; in the middle";"E:\Path with semicolon at the end;";;C:\Program Files;' | |
| - 2018/01/30 by [email protected] - Created | |
| .Link http://blogs.catapultsystems.com/chsimmons/archive/2018/01/30/parse-envpath-with-powershell/ | |
| #> | |
| $PathArray = @() |
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
| "v1.1.4322","v2.0.50727","v3.0","v3.5","v4\Full"|%{([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer)).OpenSubKey("SOFTWARE\Microsoft\NET Framework Setup\NDP\$_").GetValue('version')} |
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
| @ECHO OFF | |
| FOR /f "tokens=*" %%G in ('dir /b /a:d-s-l "%SystemDrive%\Users"') DO ( | |
| IF /I NOT "%%G"=="Public" ( | |
| IF NOT EXIST "%SystemDrive%\Users\%%G\%~2\%~1" md "%SystemDrive%\Users\%%G\%~2\%~1" | |
| xcopy.exe "%~dp0%~1" "%SystemDrive%\Users\%%G\%~2\%~1" /E /C /I /Q /H /R /K /Y | |
| ) | |
| ) |
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
| #Set-BingWallpaperAsDesktop.ps1 - [email protected] | |
| # Great help from: https://www.kittell.net/code/powershell-remove-windows-wallpaper-per-user/ | |
| #$DebugPreference = 'Continue'; #uncomment if you want to see all the steps | |
| #region types | |
| Add-Type @" | |
| using System; | |
| using System.Runtime.InteropServices; |
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
| $Credential = Get-Credential -Message User: username@DOMAIN or Domain\Username | |
| While ($true){ | |
| write-host "" | |
| $OldComputerName = Read-Host "What is the old computer name?" | |
| $NewComputerName = Read-Host "What is the new computer name?" | |
| $Restart = Read-Host "Restart the computer? Y for yes or N for no." | |
| if ($Restart -eq "Y"){ | |
| Rename-Computer -ComputerName $OldComputerName -NewName $NewComputerName -Restart -Force -DomainCredential $Credential -verbose |
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
| <# | |
| 1> User whose password is going to Expire in X days [You set the threshold] | |
| 2> And Urgent message with High Importance! whose in within 2-3 days you can set the threshold. | |
| 3> save the script as Passwordexpiryreminder.ps1 under c:\scripts for any folder and schedule to send using task scheduler, learn how to create a task. | |
| https://community.spiceworks.com/how_to/17736-run-powershell-scripts-from-task-scheduler | |
| #> | |
| $reminderdays="14" # Remind before days. | |
| $priorityreminder="3" # set Days before you want to message with High Importance. | |
| $outfile="c:\scripts\temp" # Output path to whom email was sent and days to expire. | |
| $from="Emailaddress" #Enter email senders email. |
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
| #DeleteOrphanProfiles.ps1 | |
| #Performs a SID lookup for each profile in the local computer. If it can't match the SID with a real | |
| #user, the profile gets whacked. | |
| #Needs local admin priv. | |
| $ALLLocalProfiles = Get-WmiObject -Class Win32_UserProfile | |
| foreach ($ThisProfile in $ALLLocalProfiles){ | |
| $ProfileSID = $ThisProfile.sid | |
| $ProfilePath = $ThisProfile.localpath |