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
$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 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
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 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
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 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
:: 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 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 Export-X509CertToPemFiles { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory = $true)] | |
[System.Security.Cryptography.X509Certificates.X509Certificate2]$Certificate | |
, | |
[Parameter(Mandatory = $true)] | |
[System.IO.FileInfo]$FullChainPath | |
, | |
[Parameter(Mandatory = $true)] |
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
( | |
resourcecontainers | |
| where type =~ 'microsoft.resources/subscriptions' | |
| project SubscriptionName=name, subscriptionId | |
) | join kind = inner | |
( | |
resources | |
| where type =~ 'microsoft.network/applicationgateways' | |
| project subscriptionId, AppGateway=name, httpListeners = properties['httpListeners'] | |
) on subscriptionId |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> | |
<title>Google Demo</title> | |
<style type="text/css" media="screen"> | |
.rainbow-text { | |
background-image: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet); | |
-webkit-background-clip: text; | |
-webkit-text-fill-color: transparent; |
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-HttpUrlRedirects { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[ValidateNotNullOrEmpty()] | |
[string]$Url | |
, | |
[Parameter()] | |
[AllowNull()] | |
[AllowEmptyString()] |
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
# Thanks to [Reddit](https://www.reddit.com/r/excel/comments/70r89w/need_to_delete_thousands_of_errored_named_ranges/i4huccg) | |
# for the tip on resolving the name manager issue | |
# once you've extracted your XLSX file as a zip, find the `workbook.xml` file (should be under the `xl` subfolder) | |
$wbPath = 'C:\Temp\MyExtractedXlsx\xl\workbook.xml' | |
# open this XML file / parse it as XML | |
$wb = [xml](Get-Content -Path $wbPath -encoding UTF8 -Raw) | |
# find all `definedName` elements which contain the string `#REF!`. |
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 Convert-PemToX509Cert { | |
Param ( | |
[Parameter(Mandatory)] | |
[string]$Path | |
, | |
[Parameter()] | |
[System.Text.Encoding]$Encoding = [System.Text.Encoding]::UTF8 | |
) | |
$options = [System.Text.RegularExpressions.RegexOptions]::CultureInvariant -bor [System.Text.RegularExpressions.RegexOptions]::Singleline | |
$regex = [System.Text.RegularExpressions.RegEx]::new('\-{5}BEGIN CERTIFICATE\-{5}(?<CERT>.*?)\-{5}END CERTIFICATE\-{5}', $options) |