Skip to content

Instantly share code, notes, and snippets.

View h3nryza's full-sized avatar

H3nryza h3nryza

View GitHub Profile
@h3nryza
h3nryza / pythonDateTimeForFileName.py
Created July 18, 2018 08:12
Python date time for filename use
#!/usr/bin/python
# -*- coding: <utf-8> -*-
from __future__ import print_function
import datetime
dDate = datetime.datetime.now().strftime("%m/%d/%Y %I:%M:%S %p")
dDate2 = datetime.datetime.now().strftime("%m-%d-%Y_%I%M%S%p")
location = "C:/temp/"
@h3nryza
h3nryza / powerShellImportModuleFromPath.ps1
Created July 17, 2018 17:51
Powershell import modules from path
Add-Content -Path $Profile -Value 'Import-Module "C:\Program Files (x86)\SomeProduct\PowerShell\ProductModule.psd1"' -Force
@h3nryza
h3nryza / powerShellShutDownEvents.ps1
Created July 17, 2018 17:51
Powershell last shutdown events
$arrShutdown = Get-EventLog -LogName System -EntryType Information -InstanceId 2147484722 | sort-object $_.Time -descending
foreach ($item in $arrShutdown)
{
$UserName = $item.UserName
$Message = $item.Message
$Time = $item.TimeGenerated
write-host "UserName `t:$username `nTime `t`t:$time `nMessage `t:$Message `n`n"
}
@h3nryza
h3nryza / powerShellLastReboot.ps1
Created July 17, 2018 17:50
PowerShell Last Reboot
Get-WmiObject win32_operatingsystem | select @{LABEL="LastBootUpTime";EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
@h3nryza
h3nryza / powerShellSignScripts.ps1
Created July 17, 2018 17:50
Powershell sign your scripts
Set-AuthenticodeSignature SCRIPT @(Get-ChildItem cert:\CurrentUser\My -codesign)[0]
@h3nryza
h3nryza / powerShellTailAlternative.ps1
Created July 17, 2018 17:49
PowerShell Tail alternative
Get-Content (read-host "Enter Path to logfile") -wait
@h3nryza
h3nryza / powerShellConnections.ps1
Last active July 17, 2018 17:52
Powershell connect to various consoles DNS, AD, Nutanix,
# Nutanix
#open Powershell x86
#%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe
#Add Nutanix Snappin
Add-PsSnapin NutanixCmdletsPSSnapin
Connect-NutanixCluster -server $objNutanixBlockIP -AcceptInvalidSSLCerts
# SCCM
cd (Drive of Install)
@h3nryza
h3nryza / powerShellHeaderDraft.ps1
Created July 17, 2018 17:45
Powershell header draft
<#
.Synopsis
Checks services and identifies all services that need to be running.
Attempts to restart if they are not running. Reports on success and failures
.DESCRIPTION
This script runs through all services and fixes services that should be running.
Du to space limitations it has currently only got faulty services enabled for logging.
Upon trying to restart the service 3 times and failing it will report the service down.
Down will report NOK, up OK and remediated Fixed.
Due to the number fo services Faulty services by default are enabled in one file.
@h3nryza
h3nryza / powerShellLocalGroup.ps1
Created July 17, 2018 17:45
Powershell get users of a local computer group
Get-CimInstance Win32_GroupUser | where {$_.GroupComponent -like "*admini*"} |select -ExpandProperty PartComponent
@h3nryza
h3nryza / powerShellStringManipulation.ps1
Created July 17, 2018 17:43
Powershell The string thing
[string]::Compare($a, $b, $True)
$a.StartsWith("Script")
$a.EndsWith("Script")
$a.ToLower()
$a.ToUpper()
$d.ToLower()
$a.trim()