Skip to content

Instantly share code, notes, and snippets.

@dsolodow
dsolodow / ClearWSUSSync.sql
Last active February 14, 2024 18:16
Delete WSUS Sync History
DELETE FROM [SUSDB].[dbo].[tbEventInstance]
WHERE [EventID] IN (381,382,384,386)
@dsolodow
dsolodow / Send-TeamsChat.ps1
Created September 27, 2022 17:11
Send Teams chat via Graph PS
Import-Module Microsoft.Graph.Teams
$params = @{
ChatType = 'oneOnOne'
Members = @(
@{
'@odata.type' = '#microsoft.graph.aadUserConversationMember'
Roles = @('owner')
'User@odata.bind' = "https://graph.microsoft.com/v1.0/users('UPN')"
}
@dsolodow
dsolodow / wsl.conf
Last active May 8, 2022 19:21
wsl.conf; requires Windows 10 build 17063 or higher
# https://blogs.msdn.microsoft.com/commandline/2018/01/12/chmod-chown-wsl-improvements/
# Enable extra metadata options by default
[automount]
enabled = true
root = /mnt/
options = "case=off,metadata,umask=22,fmask=11"
mountFsTab = false
options = case=off
# Enable DNS – even though these are turned on by default, we’ll specify here just to be explicit.
@dsolodow
dsolodow / Set-Signature.ps1
Last active April 21, 2022 17:28
PowerShell signature function
function Set-Signature {
[CmdletBinding()]
[Alias('sig')]
param(
[Parameter(
Mandatory,
Position = 0,
#requires -modules UpdateServices
# Site configuration
$SiteCode = "CM1" # Site code
$ProviderMachineName = "siteServer.fqdn" # SMS Provider machine name
$WSUSName = "WSUS.server.fqdn" # SUP WSUS machine name (use FQDN)
$WSUSPortNumber = "8531" # SUP WSUS Port number (default for HTTPS is 8531, and 8530 for HTTP)
$WSUSSSL = $true # set to false if not using SSL for WSUS
# Import the ConfigurationManager.psd1 module
if((Get-Module ConfigurationManager) -eq $null) {
SELECT gcs.manufacturer0 AS Make
,IIF(gcs.manufacturer0 = 'Lenovo', gcsp.Version0, gcs.model0) AS Model
,COUNT(*) AS Count
FROM [CM_XXX].[dbo].[v_GS_COMPUTER_SYSTEM] gcs
INNER JOIN [CM_XXX].[dbo].[v_GS_COMPUTER_SYSTEM_PRODUCT] gcsp ON gcsp.ResourceID = gcs.ResourceID
GROUP BY Manufacturer0
,CASE
WHEN gcs.Manufacturer0 = 'Lenovo'
THEN gcsp.Version0
ELSE gcs.Model0
@dsolodow
dsolodow / Sign-PSScript.ps1
Created June 13, 2020 23:34
PS script sign in VSCode
Register-EditorCommand -Name SignCurrentScript -DisplayName 'Sign Current Script' -ScriptBlock {
$cert = (Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert)[0]
$currentFile = $psEditor.GetEditorContext().CurrentFile.Path
Set-AuthenticodeSignature -Certificate $cert -FilePath $currentFile
}
@dsolodow
dsolodow / Add-TeamsFirewallRule.ps1
Created March 24, 2020 20:31
run as elevated; will create for each user who has profile on PC
<#
.SYNOPSIS
Creates firewall rules for Teams.
.DESCRIPTION
(c) Microsoft Corporation 2018. All rights reserved. Script provided as-is without any warranty of any kind. Use it freely at your own risks.
Must be run with elevated permissions. Can be run as a GPO Computer Startup script, or as a Scheduled Task with elevated permissions.
The script will create a new inbound firewall rule for each user folder found in c:\users.
Requires PowerShell 3.0.
#>
$dplog = Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\SMS\DP\Logging\@GLOBAL' -name LogDirectory
New-SmbShare -Path $dplog -Name DP_LOG
icacls $dplog /grant "domain users:(oi)rx"
@dsolodow
dsolodow / New-UpdateHelpJob.ps1
Last active April 29, 2019 15:26
Description for New-UpdateHelpJob.ps1
<#
Creates a scheduled task to run a daily Update-Help on the local machine
#>
$trigger = New-JobTrigger -Weekly -At "7:30 AM" -DaysOfWeek "Monday"
$option = New-ScheduledJobOption -StartIfOnBattery -RequireNetwork -RunElevated
Register-ScheduledJob -Name UpdateHelp -ScriptBlock {Update-Help -Module * -Force} -Trigger $trigger -ScheduledJobOption $option