This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MIT License | |
| Copyright (c) 2016 Xavier Plantefeve | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| MIT License | |
| Copyright (c) 2016 Xavier Plantefeve | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #region ExcelFunctions | |
| function Get-NormalizedPath ( $Path ) { | |
| if ( ( Split-Path $Path ) -match '^(\.|)$' ) { | |
| $Path = Join-Path -Path ( Get-Location ) -ChildPath ( Split-Path -Path $Path -Leaf ) | |
| } | |
| return $Path | |
| } | |
| $MethodImportCSVtoSheet = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-FolderSizeRC($Path) { | |
| if ( robocopy $Path c:\dummy /e /r:0 /w:0 /b /BYTES /nfl /ndl /np /njh /l | ? { $_ -match 'Bytes :\s*(?<size>\S+)' } ) { return [int64]$Matches.size } | |
| } | |
| function Get-FolderSizePS($Path) { | |
| return ( ls -Recurse -Path $Path -Force | measure -Property length -Sum ) | select -ExpandProperty Sum | |
| } | |
| function test($Path) { | |
| Write-Host -Object "Testing $Path" -ForegroundColor Cyan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Topic: NBA All Stars | |
| Owners: Foo Owners | |
| Users: User 1 | |
| Users: User 2 | |
| Topic: NFL MVPs | |
| Owners: Bar Owners | |
| Users: Tony Stark | |
| Users: Mitch Hedberg | |
| Users: Someone Else | |
| Topic: NBA MVPs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-LastDOW { | |
| <# | |
| .SYNOPSIS | |
| Returns the date of the last day of week you select. | |
| .DESCRIPTION | |
| Get-LastDOW will return the date of the last day of the week you select, | |
| up to one week in the past (between one week ago and yesterday). Useful, | |
| as an example, to search in logs for events only happening once a week. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-Profiles | |
| { | |
| <# | |
| .SYNOPSIS | |
| Gives a list of locally saved user profiles. | |
| .DESCRIPTION | |
| Gets a list of locally used profiles according to the registry and | |
| returns an object with information about the profile. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The following is an example, it's not a function, it's not meant to be run | |
| # as is, I just wrote it to show how creating a scheduled tak on an event | |
| # can be done in PowerShell. I wrote a small post about how it came to be, that | |
| # can be read at https://xavier.plantefeve.fr/posts/SchdTskOnEvent | |
| $class = Get-cimclass -ClassName MSFT_TaskEventTrigger -Namespace root/Microsoft/Windows/TaskScheduler | |
| $trigger = $class | New-CimInstance -ClientOnly | |
| $trigger.Enabled = $true | |
| $trigger.Subscription = '<QueryList><Query Id="0" Path="Microsoft-Windows-NetworkProfile/Operational"><Select ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Quick & dirty. Basic error checking. It works where I needed it. | |
| # | |
| # Documentation used: | |
| # - ProcMon | |
| # - https://securelink.be/blog/windows-proxy-settings-explained/ | |
| # - https://docs.microsoft.com/en-us/windows/desktop/api/Winhttp/ns-winhttp-__unnamed_struct_3 | |
| # - https://github.com/vbfox/proxyconf/blob/master/README.md | |
| # - https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/managing-bit-flags-part-1 | |
| # - https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_enum | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Laziness is a great gift | |
| # Every function will have the exact same definition, so we won't bother | |
| # copypasting. | |
| $FunctionBody = { | |
| [CmdletBinding(SupportsShouldProcess)] | |
| param( | |
| [Parameter(Mandatory, Position = 0, ValueFromPipeline)] | |
| [object[]]$inputObject | |
| ) |