Skip to content

Instantly share code, notes, and snippets.

View jespernohr's full-sized avatar

Jesper Nøhr jespernohr

View GitHub Profile
# Run first manual full backup (next run will automaticaly be incremental)
duplicity full /data/documents azure://storagecontainer001 --log-file /data/duplicity.log
# Run manual backup job in background
duplicity full /data/documents azure://storagecontainer001 --log-file /data/duplicity.log
# (press ctrl+Z)
disown -h %1
bg 1
logout
# Schedule cron job to backup every 5 minutes after midnight
# Create a backup_script.sh with "crontab -e"
export AZURE_ACCOUNT_NAME=storageaccount001
export AZURE_ACCOUNT_KEY='KEYHERE'
export PASSPHRASE='NEWRPRIVATEPASSWORDHERE'
duplicity full /data/documents azure://storagecontainer001
unset PASSPHRASE
#Check TPM Chip locally on Windows 10 PC with the following Powershell Script:
# Creating a variable for TPM WMI object.
$Tpm = Get-wmiobject -Namespace ROOT\CIMV2\Security\MicrosoftTpm -Class Win32_Tpm
# Query if TPM enabled (True/False)
$Tpm.IsEnabled().isenabled
#Clear, Enable and Activate TPM
#First, we have to load the WMI class into a variable:
$Tpm = Get-wmiobject -Namespace ROOT\CIMV2\Security\MicrosoftTpm -Class Win32_Tpm
#Then, a one liner to Clear, Enable and Activate TPM:
$Tpm.SetPhysicalPresenceRequest(14)
# Create a variable that searches Active Directory for Computers with Windows 10 Operating system.
$Win10 = Get-ADComputer -Filter {OperatingSystem -like "*10*"} `
-Properties Name, DNSHostName, OperatingSystem, `
OperatingSystemServicePack, OperatingSystemVersion, PasswordLastSet, `
whenCreated, whenChanged, LastLogonTimestamp, nTSecurityDescriptor, `
DistinguishedName |
Select-Object Name, DNSHostName, OperatingSystem, `
OperatingSystemServicePack, OperatingSystemVersion, PasswordLastSet, `
whenCreated, whenChanged, `
Get-WMIObject Win32_PerfFormattedData_Spooler_PrintQueue |
Select Name, @{Expression={$_.jobs};Label="CurrentJobs"}, TotalJobsPrinted, JobErrors
#creates a variable
$SVRNAME = 'server1.contoso.com'
#get service status
gsv -ComputerName $SVRNAME -Name Spooler
#stop service
(gsv -ComputerName $SVRNAME -Name Spooler).stop()
#start service
<#
.Synopsis
Get systeminfo on remote computer
.Description
These commands save your administrator credentials in a variable and make use of invoke command to run systeminfo on a remote computer
#>
$cred = Get-Credential
Invoke-Command –ScriptBlock {systeminfo} –ComputerName computer1.contoso.com -Credential $cred
# All credit goes to http://techibee.com/powershell/powershell-query-windows-service-start-time/1336
#
# This script displays the start date and time of a windows service
# Usage examples:
# .\Get-ServiceStartTime.ps1 -ComputerName “mytestpc1” -Name spooler
# .\Get-ServiceStartTime.ps1 -ComputerName “mytestpc1”, “mytestpc2” -Name spooler
#
[cmdletbinding()]
# this powershell code lists all poweroff and restart events from the Windows EventLog
Get-WinEvent -FilterHashtable @{logname='System'; id=1074} | ForEach-Object {
$rv = New-Object PSObject | Select-Object Date, User, Action, Process, Reason, ReasonCode, Comment
$rv.Date = $_.TimeCreated
$rv.User = $_.Properties[6].Value
$rv.Process = $_.Properties[0].Value
$rv.Action = $_.Properties[4].Value
$rv.Reason = $_.Properties[2].Value
$rv.ReasonCode = $_.Properties[3].Value