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-ShortPathName{ | |
| Param([string] $path) | |
| $MethodDefinition = @' | |
| [DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetShortPathNameW", SetLastError = true)] | |
| public static extern int GetShortPathName(string pathName, System.Text.StringBuilder shortName, int cbShortName); | |
| '@ | |
| $Kernel32 = Add-Type -MemberDefinition $MethodDefinition -Name 'Kernel32' -Namespace 'Win32' -PassThru | |
| $shortPath = New-Object System.Text.StringBuilder(500) |
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 ConvertFrom-DHCPToStatic { | |
| <# | |
| .SYNOPSIS | |
| This script takes an existing DHCP configuration and converts it to a static IP configuration | |
| .DESCRIPTION | |
| The script uses several functions to retrieve the necessary data from the existing configuration, | |
| removes that configuration, and installs the new configuration. | |
| .NOTES | |
| This script was built with the idea that there will only be one "physical" NIC in the server that is up and | |
| running when the script is run. It has not been tested in other scenarios |
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 Backup-ArbitraryWinSCPKey { | |
| <# | |
| .SYNOPSIS | |
| This script backups a user's registry keys for WinSCP | |
| .DESCRIPTION | |
| Unlike the Backup-WinSCPKey, this script allows the user to backup an arbitrary user's | |
| WinSCP key out of HKEY_USERS\<usersid>\Software\Martin Prikryl | |
| .NOTES | |
| This does require administrator rights, since the user will be delving into HKEY_USERS. | |
| .PARAMETER SamAccountName |
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 Backup-PuttyKey { | |
| <# | |
| .SYNOPSIS | |
| This script backups a user's registry keys for Putty | |
| .DESCRIPTION | |
| This script backs up the user's registry keys for Putty to a specified directory. | |
| .NOTES | |
| This script does not require any special rights | |
| .PARAMETER ExportDirectory | |
| This is the directory where the exported file will be created. |
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 Backup-ArbitraryWinSCPKey { | |
| <# | |
| .SYNOPSIS | |
| This script backups a user's registry keys for WinSCP | |
| .DESCRIPTION | |
| Unlike the Backup-WinSCPKey, this script allows the user to backup an arbitrary user's | |
| WinSCP key out of HKEY_USERS\<usersid>\Software\Martin Prikryl | |
| .NOTES | |
| This does require administrator rights, since the user will be delving into HKEY_USERS. | |
| .PARAMETER SamAccountName |
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 Backup-WinSCPKey { | |
| <# | |
| .SYNOPSIS | |
| This script backups a user's registry keys for WinSCP | |
| .DESCRIPTION | |
| This script backs up the user's registry keys for WinSCP to a specified directory. | |
| .NOTES | |
| This script does not require any special rights | |
| .PARAMETER ExportDirectory | |
| This is the directory where the exported file will be created. |
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-UserSID { | |
| <# | |
| .SYNOPSIS | |
| Retrieves a user's security identifier without the need for the ActiveDirectory Module | |
| .DESCRIPTION | |
| Retrieves a user's security identifier without the need for the ActiveDirectory Module | |
| .PARAMETER samAccountName | |
| The actual samAccountName for the user whose account the SID should be retrieved. | |
| .PARAMETER Domain | |
| This is the domain of the account to be checked. It defaults to the domain of the user |
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 Clear-CitrixDesktopShortcuts { | |
| <# | |
| .SYNOPSIS | |
| Deletes desktop shortcuts that are generated by Citrix Workspace App/Receiver | |
| .DESCRIPTION | |
| The script retrieves all of the shortcuts from the user's desktop folder and checks | |
| each of the .lnk files for a target path that matches 'AppData\Roaming\Citrix\SelfService'. | |
| If the link file matches, the file is deleted. | |
| .NOTES | |
| This uses the wscript.shell object, and the script does release all of the COM objects to prevent memory leaks. |
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
| if (-not ('wtsapi' -as [type])) { | |
| Add-Type -ErrorAction SilentlyContinue -TypeDefinition @' | |
| using System; | |
| using System.Runtime.InteropServices; | |
| public enum WTS_CONNECTSTATE_CLASS | |
| { | |
| WTSActive, | |
| WTSConnected, | |
| WTSConnectQuery, |
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-ValidatedCredential { | |
| <# | |
| .SYNOPSIS | |
| Retrieves a credential from the user with the standard Windows dialog, and | |
| then it validates that the password is correct for the account. | |
| .DESCRIPTION | |
| Uses the standard dialog with the option to customize the title, the prompt text, and | |
| to prefill a domain name and user name. The credential is then tested against the domain | |
| to validate that the password is correct. If it is not, the user is prompted again. |
NewerOlder