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
Import-Module "D:\Coding\PowerShell\Modules\remove-OldFiles.psm1" | |
remove-OldFiles -Path 'D:\Coding' -ExcludeFolders "Bootstrap Learning","PowerShell","Waaah!" | |
#the folder Waaah! dont exists in the Folder mentioned above. so in the PSM there is a write-Host line to display this error. but i dont see it when i call the function from the ps1 script. |
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
param( | |
$Source = "c:\users\USER1\desktop\test\folder1", | |
$Destination = "c:\users\USER1\desktop\test\folder2" | |
) | |
$Sources = Get-ChildItem $Source -recurse -depth 4 | Where-Object {$_.name -like "*``, *`` *``(*2016)"} | Select-Object -ExpandProperty FullName | |
Push-Location $Source | |
foreach($SourcePath in $Sources) { | |
$DestPath = Join-Path $Destination (Resolve-Path $SourcePath -Relative) |
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
#.Synopsis | |
# Generate a bunch of test modules to demonstrate ModuleSpec "cyclic dependency" bug | |
#.Example | |
# Write-ModuleSpecRepro | |
# | |
# Uses the default values to create a series of modules which will fail to import | |
#.Example | |
# Write-ModuleSpecRepro -Depth 6 -ModuleSpec First2 | |
# | |
# Creates a series of modules where only two modules have specified the versions of their dependencies, |
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-VSCodeProduct { | |
#.Synopsis | |
# Get the current VSCode Product Info | |
Get-Item "${Env:ProgramFiles(x86)}\Microsoft VS Code*\Resources\app\product.json" | Get-Content | ConvertFrom-Json | |
} | |
function Get-WebFile { | |
#.Synopsis |
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 Enable-LocalRemoting { | |
<# | |
.Synopsis | |
Generate and configure a local self-signed SSL certificate and configure PowerShell remoting | |
#> | |
param( | |
# If set, recreates existing certificates, listeners and firewall rules | |
[switch]$Force | |
) | |
end { |
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
Add-Type @" | |
using System; | |
using System.Runtime.InteropServices; | |
public class NativeConsoleMethods | |
{ | |
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] | |
public static extern IntPtr GetStdHandle(int handleId); |
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 Invoke-Parallel { | |
<# | |
.SYNOPSIS | |
Function to control parallel processing using runspaces | |
.DESCRIPTION | |
Function to control parallel processing using runspaces | |
Note that each runspace will not have access to variables and commands loaded in your session or in other runspaces by default. | |
This behaviour can be changed with parameters. |
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
<# | |
based on a comment from Matt Penny | |
function todo { | |
param ([string]$TodoText) | |
write-host -foregroundcolor DarkYellow ” [o] Todo: $TodoText” | |
} | |
Get more from Matt at https://mattypenny.net/ |
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
#.Synopsis | |
# Returns TRUE if the current PowerShell is running elevated, FALSE otherwise. | |
[CmdletBinding()]param() | |
$IsElevated = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |
if($IsElevated -ne ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole("Administrators")) { | |
Write-Warning "String Method does not work" | |
} | |
if($IsElevated -ne [Bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -eq "S-1-5-32-544")) { |
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
<?xml version="1.0" encoding="utf-8"?> | |
<key name="Software"> | |
<key name="ConEmu"> | |
<key name=".Vanilla" modified="2016-09-13 00:43:10" build="160904"> | |
<value name="StartType" type="hex" data="02"/> | |
<value name="CmdLine" type="string" data=""/> | |
<value name="StartTasksFile" type="string" data=""/> | |
<value name="StartTasksName" type="string" data="{Shells::PowerShell}"/> | |
<value name="StartFarFolders" type="hex" data="00"/> | |
<value name="StartFarEditors" type="hex" data="00"/> |