This file contains 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-FileType { | |
<# | |
.SYNOPSIS | |
Try to get the file type based on it's file signature. | |
.DESCRIPTION | |
This function uses Get-FileSignature by Boe Prox and a list of | |
known file signatures to try to find the file type of a given file. | |
.EXAMPLE | |
Get-FileType c:\path\to\file.pdf | |
.LINK |
This file contains 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( | |
[Parameter(ParameterSetName = "Inputparameter",Position=1,Mandatory=$True)] | |
[String]$sharepointUrl, | |
[Parameter(ParameterSetName = "Inputparameter",Position=2,Mandatory=$True)] | |
[String]$targeturl, | |
[Parameter(ParameterSetName = "Inputparameter",Position=3,Mandatory=$True)] | |
[String]$Sourceurl, | |
[Parameter(ParameterSetName = "Inputparameter",Position=4,Mandatory=$True)] | |
[String]$SourceDocumentLib, | |
[Parameter(ParameterSetName = "Inputparameter",Position=4,Mandatory=$True)] |
This file contains 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
# Start-FileSystemWatcher.ps1 - File System Watcher in Powershell. | |
# Brought to you by MOBZystems, Home of Tools | |
# https://www.mobzystems.com/code/using-a-filesystemwatcher-from-powershell/ | |
[CmdletBinding()] | |
Param( | |
# The path to monitor | |
[Parameter(Mandatory=$true, Position=0)] | |
[string]$Path, | |
# Monitor these files (a wildcard) |
This file contains 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
# Get all files/agrs passed to the script | |
$SourceFiles = $PsBoundParameters.Values + $args | |
$FilesInfo = @() | |
ForEach($FileFullPath in $SourceFiles) | |
{ | |
# Get file directory | |
$File = Get-Item -LiteralPath $FileFullPath | |
# Calculate file MD5 |
This file contains 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-MultipartRequestParameters(){ | |
<# | |
.SYNOPSIS | |
Function returnds object withi contains parameters needed for invoking CmdLets like Invoke-WebRequest or Invoke-RESTRequest | |
.DESCRIPTION | |
Function returnds object withi contains parameters needed for invoking CmdLets like Invoke-WebRequest or Invoke-RESTRequest. | |
Function automatically recognizes file paths in values and determinates it's Content-Type | |
.EXAMPLE |
This file contains 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
# Define external script paths and arguments | |
$ExternalScript_FullPath = "$((Get-Item $MyInvocation.MyCommand.Path).Directory.FullName)\ExternalScript.ps1" | |
$ExternalScript_Args = @{ | |
$param = $value | |
} | |
# Run External Script and save output to variable | |
Invoke-Expression "$ExternalScript_FullPath @ExternalScript_Args" | Tee-Object -Variable ExternalScript_Output | |
# Show output |
This file contains 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-DatesByWeekNumber | |
{ | |
param( | |
[int]$year = (Get-Date).Year, | |
[int]$weekOfYear = (Get-Date -UFormat %W) | |
) | |
# Get 1st of january of given year | |
$jan1 = Get-Date("$year-01-01") |
This file contains 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 | |
TBD | |
.DESCRIPTION | |
TBD | |
.URL https://gist.github.com/Forket/39c966cc2576c65e6373721fd345657a | |
#> |