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
#!/bin/sh | |
# Line to test if POSH is even executing | |
/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command "Get-Location | Out-File C:\Temp\test.txt" | |
if /c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command "If ((Get-AuthenticodeSignature .\install.ps1).Status -ne 'Valid') { Exit 1 }" | |
then | |
cat <<\EOF | |
The install.ps1 file has a valid signature. | |
EOF |
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 Write-Json { | |
param( | |
[Parameter( | |
Mandatory=$true, | |
HelpMessage = "Json object to be printed out in human readable format." | |
)][PSCustomObject]$Json, | |
[int]$tab=1, | |
[bool]$array=$false | |
) |
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
<# | |
.SYNOPSIS | |
Mimics the command prompt Pause command. | |
.DESCRIPTION | |
Powershell doesn't have a Pause command that Prompts the user with "Press any key to continue..." and waits for a response. | |
This brings that command to PowerShell and allows you to customize the message. | |
.PARAMETER Message | |
The paused Message can be customzied by passing a string. | |
.INPUTS |
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
$a = (Get-WmiObject -ComputerName 'myserver.fqdn' -Namespace 'root\SMS\Site_XXX' -Class 'SMS_Driver' | ?{!(test-path $_.ContentSourcePath)}) | |
$a | %{$_.delete()} |
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
@echo off | |
setlocal | |
SET /A RETRYMAX=10 | |
SET LOG=%SystemRoot%\Logs\ServiceRecovery.log | |
FOR /F "tokens=2*" %%a in ('sc query %1 ^| findstr STATE') do SET STATUS=%%b | |
SET STATUS=%STATUS: =% | |
IF ERRORLEVEL 1 goto _errawr | |
IF "%STATUS%"=="4RUNNING" goto:eof |
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
Option Explicit | |
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
' Usage: | |
' cscript.exe ProductsInstalled.vbs | |
' | |
' Description: | |
' This will Query WMI for all of the Programs installed with Windows Installer - which covers about 90% | |
' of our supported applications. Results are written to ProductsInstalled.txt in the Working Dir. | |
' | |
' Output Format: |
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
Option Explicit | |
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
' Usage: | |
' cscript.exe Uninstaller.vbs ApplicationName [LogFileName] | |
' | |
' Parameters: | |
' ApplicationName The Product Name of the Program you want to Uninstall. This will | |
' remove all instances of the program, so be as specific as you want. | |
' - Example: "Adobe" would remove all Adobe products (anything with Adobe in the Name) | |
' - Example: "Adobe Reader" will remove all versions of Adobe Reader. |
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
[string] $Path = 'OU=foo,OU=test,DC=domain,DC=com' | |
try { | |
$ou_exists = [adsi]::Exists("LDAP://$Path") | |
} catch { | |
# If invalid format, error is thrown. | |
Throw("Supplied Path is invalid.`n$_") | |
} | |
if (-not $ou_exists) { | |
Throw('Supplied Path does not exist.') |
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
[string] $RootOU = 'OU=test,DC=domain,DC=com' | |
[string] $Path = 'OU=foo' | |
try { | |
$ou_exists = [adsi]::Exists("LDAP://$Path") | |
} catch { | |
# If invalid format, error is thrown. | |
Write-Debug "Supplied Path is invalid.`n$_" | |
# It's probably the abbreviated version, so let's tack on the Root OU and confirm exists. | |
Write-Debug 'Placing Path in Root OU and re-verifying ...' | |
$Path = "$Path,$RootOU" |
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
{% for computer in 'TEST001','TEST002','TEST003' %} | |
{% if grains['nodename'] == computer %} | |
is_test_computer: True | |
{% else %} | |
is_test_computer: False | |
{% endif %} | |
{% else %} | |
is_test_computer: False | |
{% endfor %} |
OlderNewer