Skip to content

Instantly share code, notes, and snippets.

[CmdletBinding(SupportsShouldProcess)]
Param (
...
)
...
$current_item = 'X'
if ($PSCmdlet.ShouldProcess($name, "My very dangerous operation on $current_item")) {
...
}
...

Security Checklist

B. IT

Items marked without a *: applicable only to internal it.
Items marked with a *: applicable to both customers and internal it.

  • Security:
  • [MANDATORY] No empty/default passwords. *
  • [HIGH] Theft-protection of moving equipment containing data, e.g. corporate laptops/phones
[CmdletBinding()]
param()
$source = '\\greatgazoo\FTPRoot\internal\Setup b*'
$dest = 'c:\MyForce\Setups'
$products = @(
'AgentMonitoringService',
'AskiaFace',
'Cati',
# Prompt (Mathias Weiss, Keynote Sigos)
#---($(uname -r))\
export PS1='\e[1;30m\
-== ( RC: $(EXC=$?; if [ $EXC == 0 ] ;then echo \[\e[32m\]OK 0; else echo \[\e[31m\]ERR $EXC; fi)\[\e[0m\] \e[1;30m)\
---(\d \t)\
---($(uptime | grep -o "average:.*" | cut -d: -f 2 | sed -e "s/ //"))\
---[\[\e[0m\] \w \e[1;30m] ==-\n\
\u@\h \W $(if [ "$(id -u)" = "0" ] ; then echo "\[\e[0;31m\]#\[\e[0m\]"; else echo "\[\e[0m\]\[\e[0;35m\]$\[\e[0m\]"; fi)> '
@WimObiwan
WimObiwan / zabbix_agent
Last active March 2, 2017 09:51
Zabbix_agent init.d script Centos 7
#!/bin/sh
#
# zabbix_agentd start/stop script for CentOS 7
#
# * Save as /etc/rc.d/init.d/zabbix_agent
# * Run /sbin/chkconfig --add zabbix_agent
# * Start with service start zabbix_agent
#
# Source function library.
$key = @{}
# First 1-on-1 mapping of all characters
for ($i = 0; $i -le 255; $i++) { $key[[char]$i] = [char]$i }
#Shift all alphabet characters on character backwards
for ($i = [byte][char]'B'; $i -le [byte][char]'Z'; $i++) { $key[[char]$i] = [char]($i - 1) }
$key[[char]'A'] = [char]'Z'
for ($i = [byte][char]'b'; $i -le [byte][char]'z'; $i++) { $key[[char]$i] = [char]($i - 1) }
$key[[char]'a'] = [char]'z'
#$hourlyStartTimes = @('08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00')
$hourlyStartTimes = @(for ($i = 8; $i -le 19; $i++) { "$($i):00" } )
$hourlyTriggers = @($hourlyStartTimes | %{ New-JobTrigger -Daily -At $_ -RandomDelay '1:00' })
$nightlyTrigger = New-JobTrigger -Daily -At '0:00' -RandomDelay '4:00'
Register-ScheduledJob -Name 'Backup GIT Incremental' -Trigger $hourlyTriggers -ScriptBlock { C:\SourceGIT\backup.ps1 -LastDays 5 }
Register-ScheduledJob -Name 'Backup GIT' -Trigger $nightlyTrigger -ScriptBlock { C:\SourceGIT\backup.ps1 }
#Troubleshooting:
[CmdletBinding(SupportsShouldProcess)]
param
(
[Parameter(Mandatory = $True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)]
[string]$Repository,
[Parameter(Mandatory = $True)]
[string]$Target,
[Parameter(Mandatory = $False)]
# Based on http://stackoverflow.com/a/38381054/5247022
function Invoke-Git {
<#
.Synopsis
Wrapper function that deals with Powershell's peculiar error output when Git uses the error stream.
.Example
Invoke-Git ThrowError
$LASTEXITCODE
[CmdletBinding()]
Param (
[string] $RepositoryPath = '.'
)
function Split-GitPath ([string] $path) {
$pos = $path.LastIndexOf('/')
if ($pos -eq -1) {