Skip to content

Instantly share code, notes, and snippets.

@pstakuu
pstakuu / visiosharepointmockup
Created February 4, 2021 18:17
mockup of creating visio diagram from SharePoint site report
$folder1 = new-object -TypeName psobject -Property @{
Name = "folder1"
List = "DocLib1"
Site = "Web1"
}
$folder2 = new-object -TypeName psobject -Property @{
Name = "folder2"
List = "DocLib1"
Site = "Web1"
}
@pstakuu
pstakuu / Parse-RADIUSLogs.ps1
Last active April 12, 2021 14:40
Parsing of Windows RADIUS Logs for date, status,distinguishedname,username,sourceIP
$files= Get-childitem Y: | select -last 90
function Process-RADIUSLogs () {
[CmdletBinding()]
param(
$file,
[switch]$onlyAccepted
)
Write-Verbose "Processing $file"
$data = get-Content $file
$exampleData = [PsCustomObject]@{
SimpleField1 = "user"
ComplexField2 = @{
Property1 = "value1"
Property2 = "value2"
}
}
<#
@pstakuu
pstakuu / Check-WindowsUpdatesandAV.ps1
Created July 7, 2022 21:53
Windows Updates and AV
#credits
#https://stackoverflow.com/questions/7330187/how-to-find-the-windows-version-from-the-powershell-command-line
#https://serverfault.com/questions/1035099/getting-full-windows-version-on-batch-or-powershell-like-microsoft-windows-v
function Check-WUAV {
param($servers)
BEGIN{
$scriptblock = {
@pstakuu
pstakuu / Get-SPOSpecificFolderStats.ps1
Last active August 19, 2022 16:37
Get-SPOSpecificFolderStats
#Parameters
$SiteURL = "https://company.sharepoint.com"
Connect-PnPOnline $SiteURL -UseWebLogin
$FolderSiteRelativeURL = "/Shared Documents/EC/Projects"
$downloadPath = "C:\temp"
Function Get-SPOFolderStats
{
@pstakuu
pstakuu / get-spospecificfolderlimited
Created August 10, 2022 01:27
Limited run for test
$SiteURL = "https://company.sharepoint.com"
Connect-PnPOnline $SiteURL -UseWebLogin
$FolderSiteRelativeURL = "/Shared Documents/path/path"
$downloadPath = "C:\temp"
$folder = Get-PnpFolder $FolderSiteRelativeURL
Get-PnPProperty -ClientObject $Folder -Property ServerRelativeUrl, Folders | Out-Null
$Web = Get-PnPWeb -Includes ServerRelativeUrl
$SiteRelativeUrl = $Folder.ServerRelativeUrl -replace "$($web.ServerRelativeUrl)", [string]::Empty
#show items
@pstakuu
pstakuu / Parse-O365Endpoints.ps1
Last active August 11, 2022 19:00
Parse out the IPV4 and URL O365 endpoint for conversion to JSON file for updating geoblock exceptions
$guid = New-Guid
$webdata = Invoke-RestMethod -Uri "https://endpoints.office.com/endpoints/worldwide?clientrequestid=$guid"
<# webdata example
id : 65
serviceArea : Common
serviceAreaDisplayName : Microsoft 365 Common and Office Online
urls : {account.office.net}
ips : {52.108.0.0/14, 2603:1006:1400::/40, 2603:1016:2400::/40, 2603:1026:2400::/40...}
tcpPorts : 80,443
@pstakuu
pstakuu / File-Aging.ps1
Created August 12, 2022 13:59
searches directories and outputs file ages by various time
# FileAging.ps1
# This script developed and tested with PowerShell RTM
Param($dir)
if ($dir -isnot [string]) {
Write-Host “ERROR: You must specify a directory path!” `
-foregroundcolor “RED” -backgroundcolor “Black”;`
return
}
@pstakuu
pstakuu / ConvertTo-MP3.ps1
Created August 12, 2022 14:02
converts other sound formats to mp3 - can't remember where I grabbed this from but put it together and requires VLC
function ConvertToMp3( $file, [string] $vlc = 'C:\Program Files\VideoLAN\VLC\vlc.exe') {
PROCESS {
$codec = 'mp3';
$oldFile = Get-Item $file;
$newFile = $oldFile.FullName.Replace($oldFile.Extension, ".$codec");
&"$vlc" -I dummy "$oldFile" ":sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst=$newFile}" vlc://quit | out-null;
#Only remove source files when you are sure that the conversion works as you want
@pstakuu
pstakuu / Join-Object.ps1
Created August 12, 2022 14:08
Can't remember where I got this either... but it's been useful for combining like SQL
function AddItemProperties($item, $properties, $output)
{
if($item -ne $null)
{
foreach($property in $properties)
{
$propertyHash =$property -as [hashtable]
if($propertyHash -ne $null)
{
$hashName=$propertyHash[“name”] -as [string]