This file contains 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 Compare-ArrayItems { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[PSObject[]]$ReferenceArray | |
, | |
[Parameter(Mandatory)] | |
[PSObject[]]$DifferenceArray | |
) | |
# note: this treats the arrays as sets; i.e. doesn't care what position items are in within an array, or if the same item occurs multiple times |
This file contains 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 Receive-TcpServerResponse { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory = $true)] | |
[System.IO.StreamReader]$StreamReader | |
) | |
# useful notes on SMTP https://www.rfc-editor.org/rfc/rfc5321.html / http://www.tcpipguide.com/free/t_SMTPRepliesandReplyCodes-3.htm / FTP on https://www.w3.org/Protocols/rfc959/4_FileTransfer.html | |
$return = [PSCustomObject]@{PSTypeName='TcpResponse';Code=$null;Text=''} # don't need code, but no harm in leaving it (it was here from: ) | |
$hasMoreData = $true | |
#Write-Verbose ': Awaiting Server Response' |
This file contains 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-FilesInDirectory { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[string]$Path | |
, | |
[Parameter(Mandatory)] | |
[string]$SearchPattern | |
, |
This file contains 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
import com.microsoft.sqlserver.jdbc.*; | |
import java.sql.*; | |
public class DBTest { | |
public static void main(String[] args) { | |
if (args.length != 1) { | |
System.out.println("Please provide a connection string as an argument when calling this method; exactly 1 argument expected; received: " + args.length); | |
return; |
This file contains 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 Import-IISLog { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[System.IO.FileInfo]$Path | |
, | |
[Parameter()] | |
[Microsoft.PowerShell.Commands.FileSystemCmdletProviderEncoding]$Encoding = [Microsoft.PowerShell.Commands.FileSystemCmdletProviderEncoding]::Ascii | |
) | |
Begin { |
This file contains 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
$username = 'username' | |
$password = 'password' | |
$computer = $env:COMPUTERNAME | |
Add-Type -AssemblyName 'System.DirectoryServices.AccountManagement' | |
$obj = [System.DirectoryServices.AccountManagement.PrincipalContext]::new('machine',$computer) | |
$obj.ValidateCredentials("$computer\$username", $password) |
This file contains 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
void Main() | |
{ | |
var usr = @"myDomain\myUser"; | |
var pwd = Util.GetPassword(usr); //linqpad util library | |
var uri = "https://webdavendpoint.example.com/somefolder/"; | |
var fn = @"c:\temp\filetouploadTestData.txt"; | |
var rn = "remoteFilenameTestData.txt"; | |
var wd = new BasicWebDavClient(usr, pwd, uri); | |
wd.Put(fn, rn); |
This file contains 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
Param( | |
[Parameter(Mandatory = $true)] | |
[string]$ComputerName | |
, | |
[Parameter()] | |
[int]$Port = 25 | |
, | |
[Parameter()] | |
[System.Security.Authentication.SslProtocols]$SslProtocols = [System.Security.Authentication.SslProtocols]::GetValues([System.Security.Authentication.SslProtocols]) | |
, |
This file contains 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
:: Recursively take ownership of all files under a folder, and amend their access to grant full ownership to admins. | |
takeown /R /A /D Y /F c:\temp\path | |
:: /R = Recursive | |
:: /A = Ownership to Admins | |
:: /D Y = answer Yes to any questions (/D N would answer No) | |
:: /F c:\temp\path = which path to run the command against | |
icacls c:\temp\path /grant Administrators:F /T /C | |
:: c:\temp\path The path to run the command against |
This file contains 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 Export-X509CertToPemFiles { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory = $true)] | |
[System.Security.Cryptography.X509Certificates.X509Certificate2]$Certificate | |
, | |
[Parameter(Mandatory = $true)] | |
[System.IO.FileInfo]$FullChainPath | |
, | |
[Parameter(Mandatory = $true)] |