[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
Function Prompt-For-Date
{
Param(
[string]$sDatePrompt = "Select a Date"
) #End Param
$script:dtmDate = ''
$objForm = New-Object Windows.Forms.Form
$objForm.Text = $sDatePrompt
$objForm.Size = New-Object Drawing.Size @(300,300)
$objForm.StartPosition = "CenterScreen"
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({
if ($_.KeyCode -eq "Enter")
{
$script:dtmDate = $objCalendar.SelectionStart
$objForm.Close()
}
})
$objForm.Add_KeyDown({
if ($_.KeyCode -eq "Escape")
{
$objForm.Close()
}
})
$objCalendar = New-Object System.Windows.Forms.MonthCalendar
$objCalendar.ShowTodayCircle = $False
$objCalendar.MaxSelectionCount = 1
$objForm.Controls.Add($objCalendar)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
return $script:dtmDate
}
$dateReturned = Prompt-For-Date -sDatePrompt "Please Select A Date"
Write-Host "Date:" $dateReturned
function Copy-SelectedFile
{
[CmdletBinding()]
param(
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateScript({Test-Path -path $_})]
[string]$SourcePath,
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[string]$DestinationPath,
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[System.Management.Automation.PSCredential]$Credential = (Get-Credential),
[parameter(ValueFromPipelineByPropertyName = $true)]
[datetime]$MinimumAgeTime = ([datetime]::now),
[parameter(ValueFromPipelineByPropertyName = $true)]
[datetime]$MaximumAgeTime
)
$Files = Get-ChildItem -Path $SourcePath | Where-Object { $_.LastWriteTime -gt $MinimumAgeTime -and $_.LastWriteTime -lt $MaximumAgeTime}
$Destination = New-Item -Path $DestinationPath -ItemType Directory -Name $MinimumAgeTime.ToString('ddMMyy')
Copy-Item -Path $Files -Destination $Destination -Credential $Credential -Recurse
}
ASKER
ASKER
Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.
TRUSTED BY
Open in new window
to the first code, and run something likeOpen in new window
or similar. Note that you need to dates for the function.