I'm trying to write a simple function that gets files from designated directory filters them with one criteria a then puts the results back. I came up with this as below. It works if it is not placed in a function and when placed in one it only runs Get-ChildItem and I have no idea why.
This is my simple code:
function Move-AllSigned
{
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string] $Path
)
Process {
$TempPath = Join-Path -Path $Path -ChildPath '\1'
Write-Host $TempPath
Set-Location -Path $Path
Get-ChildItem -Name "*sig*" | Move-Item -Destination $TempPath
Remove-Item *.pdf
Set-Location -Path $TempPath
Move-Item * -Destination $Path
}
}