Skip to content

Instantly share code, notes, and snippets.

View adbertram's full-sized avatar

Adam Bertram adbertram

View GitHub Profile
<?xml version= "1.0"?>
<functions>
<ActiveDirectory>
<FGPP>
<function name="Validate-IsFgppLinkedToAdminGroup" status="enabled" description="" description="" severity="1" category="BestPractice" />
<function name="Validate-IsFgppLinkedToNonGlobalGroup" status="enabled" description="" severity="1" category="BestPractice" />
</FGPP>
<GPO>
</GPO>
<LDAP>
<?xml version= "1.0"?>
<functions>
<ActiveDirectory>
<FGPP>
<function name="Validate-IsFgppLinkedToAdminGroup" status="enabled" description="" description="" severity="1" category="BestPractice" />
<function name="Validate-IsFgppLinkedToNonGlobalGroup" status="enabled" description="" severity="1" category="BestPractice" />
</FGPP>
<GPO>
</GPO>
<LDAP>
#Requires -Version 4
<#
.NOTES
Created on: 10/8/2014
Created by: Adam Bertram
Filename: Start-ModPollMonitor.ps1
Requirements: Share permissions for Everyone on destination share
The source computer account Modify NTFS rights on destination folder
.DESCRIPTION
function Convert-TimeStringToTimeSpan($TimeString) {
$AllowedLabels = (New-TimeSpan).Psobject.Properties.Name
## Add the singular values as well
$AllowedLabels += $AllowedLabels | foreach { $_.TrimEnd('s') }
## Strip the 'for' string
$TimeString = $TimeString.TrimStart('for ')
## Attempt to split on the 'and' string in case it was something like 1 hour and 15 minutes
$Values = $TimeString -split ' and '
$Hours = 0
function Get-LoggedOnUserSID {
<#
.SYNOPSIS
This function queries the registry to find the SID of the user that's currently logged onto the computer interactively.
#>
[CmdletBinding()]
param ()
process {
try {
New-PSDrive -Name HKU -PSProvider Registry -Root Registry::HKEY_USERS | Out-Null
function Get-InstalledSoftware {
<#
.SYNOPSIS
Retrieves a list of all software installed
.EXAMPLE
Get-InstalledSoftware
This example retrieves all software installed on the local computer
.PARAMETER Name
The software title you'd like to limit the query to.
function Find-InTextFile
{
<#
.SYNOPSIS
Performs a find (or replace) on a string in a text file or files.
.EXAMPLE
PS> Find-InTextFile -FilePath 'C:\MyFile.txt' -Find 'water' -Replace 'wine'
Replaces all instances of the string 'water' into the string 'wine' in
'C:\MyFile.txt'.
@adbertram
adbertram / gist:9b751cdc917730d186c6
Created October 15, 2015 21:26
get-computerinfo-revision
#Requires -version 2.0
function Get-ADSiteFromComputer
{
<#
.Synopsis
Return the site that a computer is member of
.DESCRIPTION
Given a computer name, it looks up its IP address and checks which AD site's subnet it is in
.EXAMPLE
$list = @'
1 Partridge in a pear tree
2 Turtle Doves
3 French Hens
4 Calling Birds
5 Golden Rings
6 Geese a laying
7 Swans a swimming
8 Maids a milking
9 Ladies dancing
$date = get-date
if (get-eventlog -logname system -source disk -newest 1 | where-object { [dateTime]$_.Time -eq $date })
{
GET-WMIOBJECT –class win32_logicaldisk | where { $_.DriveType -eq 3 } | foreach { fsutil dirty set $_.DeviceID }
}
else
{
Write-Output "nothing to do!"
start-sleep -s 10