Skip to content

Instantly share code, notes, and snippets.

View dotps1's full-sized avatar

Thomas Malkewitz dotps1

View GitHub Profile
@dotps1
dotps1 / Invoke-AppveyorBuild.ps1
Last active June 21, 2016 20:28
Appveyor Build
#requires -Modules Configuration, Pester, PSScriptAnalyzer
try {
Set-Location -Path $env:APPVEYOR_BUILD_FOLDER -ErrorAction Stop
$timestamp = Get-Date -uformat "%Y%m%d-%H%M%S"
$resultsFile = "Results_${timestamp}.xml"
Import-Module -Name .\$env:APPVEYOR_PROJECT_NAME -Force -ErrorAction Stop
Invoke-Pester -Path '.\Tests' -OutputFormat NUnitXml -OutputFile ".\$resultsFile" -PassThru -ErrorAction Stop |
\Windows\SOFTWA~1\DATAST~1\DATAST~1.EDB
\Windows\SoftwareDistribution\Datastore\DataStore.edb
\Windows\SOFTWA~1\DATAST~1\Logs\*.jrs
\Windows\SoftwareDistribution\Datastore\Logs\*.jrs
\Windows\SOFTWA~1\DATAST~1\Logs\Edb.chk
\Windows\SoftwareDistribution\Datastore\Logs\Edb.chk
\Windows\SOFTWA~1\DATAST~1\Logs\Tmp.chk
\Windows\SoftwareDistribution\Datastore\Logs\Tmp.chk
\Windows\Security\Database\*.edb
\Windows\Security\Database\*.sdb
@dotps1
dotps1 / WindowsUpdateAgentReset.ps1
Last active January 5, 2024 08:22
Resets the Windows Update Agent components.
<#
.SYNOPSIS
Resets the requried components of the Windows Update Agent.
.DESCRIPTION
Stops required services.
Removes cached files/folders used by the Windows Update Agent.
Resets the permissions on the bits and wuauserv services.
Registers dlls needed by the bits/Windows Update Agent.
Removes lingering registry entries from SUS if present.
Restarts all the services that where stopped.
@dotps1
dotps1 / Find-NthIndexOf.ps1
Last active January 5, 2024 08:07
Finds the nth index of a char in a string.
<#
.SYNOPSIS
Finds the nth index of a char in a string.
.DESCRIPTION
Finds the nth index of a char in a string, returns -1 if the char does not exist, or if nth is out of range.
.INPUTS
System.Char.
System.String.
System.Int.
.OUTPUTS
@dotps1
dotps1 / .\Invoke-GitLabBuild.ps1
Created October 31, 2016 17:41
GitLab CI Files
#requires -Modules Configuration, Pester, PSScriptAnalyzer
[CmdletBinding()]
[OutputType()]
$ErrorActionPreference = "Stop"
try {
# Setup environment.
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Confirm:$false -Force |
@dotps1
dotps1 / ActiveSyncUserSync.ps1
Last active January 5, 2024 08:07
Sync Active Sync Users to group, and remove inactive devices.
$members = Get-ADGroupMember -Identity "ActiveSyncUsers"
foreach ($mailbox in (Get-CASMailbox -Filter { HasActiveSyncDevicePartnership -eq $true } -ResultSize Unlimited)) {
# If the user is disabled, remove all paired devices and ensure the user is removed from the group.
if ((Get-ADUser -Identity $mailbox.DistinguishedName).Enabled -eq $false) {
foreach ($device in (Get-MobileDevice -Mailbox $mailbox.DistinguishedName)) {
Remove-MobileDevice -Identity $device.Identity -Confirm:$false
}
if ($mailbox.DistinguishedName -in $members.DistinguishedName) {
Remove-ADGroupMember -Identity "ActiveSyncUsers" -Members $mailbox.DistinguishedName -Confirm:$false
@dotps1
dotps1 / BattleNetClientFix.ps1
Created November 27, 2016 21:16
This will remove all the folders to allow you to log back into battle.net.
#requires -RunAsAdministrator
<#
.SYNOPSIS
This will remove all the folders to allow you to log back into battle.net.
.DESCRIPTION
This will remove all the folders to allow you to log back into battle.net.
.INPUTS
None
.OUTPUTS
@dotps1
dotps1 / WinPENanoDomainJoin.ps1
Last active January 9, 2019 20:57 — forked from Ryan2065/WinPENanoDomainJoin.ps1
Nano domain join for use in SCCM task sequence!
$source = @'
using System;
using System.Security.Principal;
using System.Runtime.InteropServices;
namespace ECGCAT
{
public class Kernel32
{
[DllImport("Kernel32.dll", SetLastError = true)]
@dotps1
dotps1 / Set-ManageDocumentsPermission.ps1
Created January 23, 2017 19:46
Set Manage Documents permission on a Print Server.
# Get the SID of the group to give Permissions to.
$sid = ([System.Security.Principal.NTAccount]"DOMAIN\GROUPNAME").Translate(
[System.Security.Principal.SecurityIdentifier]
)
# Build an Access Control Entry object giving the group the Manage Documents permission. 983088 is the access mask for Manage Documents only.
$ace = New-Object -TypeName System.Security.AccessControl.CommonAce -ArgumentList @(
@([System.Security.AccessControl.AceFlags]::ObjectInherit, [System.Security.AccessControl.AceFlags]::InheritOnly), [System.Security.AccessControl.AceQualifier]::AccessAllowed, 983088, $sid, $false, $null
)
@dotps1
dotps1 / WannaCryVulnerbilityTesting.ps1
Last active May 31, 2017 13:31
Test for WannaCry Vulns using PSJobs
#requires -module ActiveDirectory
# Input computers.
$threshold = (Get-Date).AddDays(-180)
$computers = Get-ADComputer -Filter { OperatingSystem -notlike "*server*" -and OperatingSystem -like "*windows*" -and PasswordLastSet -gt $threshold } |
Select-Object -ExpandProperty Name |
Sort-Object -Property Name
# Make sure there are not existing jobs.
Get-Job |