Hi All
again experimenting with Sapien, but this is likely a general question so thought i would try here ![]()
i am using a gui & some date selection, now my issue iss the data selection adds a time to the end which i cant use for the exchange dumpster command (as below in the $start)
05 September 2016 00:00:00
i realise there is quite a bit of uneeded code here but was just trying to see why the listbox would show a short date and then pass a longer format to the command line. Appreciate any help
$formDumpsterRestore_Load={
#TODO: Initialize Form Controls here
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
$Username = "global\mark.prior"
$Password = ConvertTo-SecureString "xxxxxxxxx" -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$SESJA_EX = New-PSSession -Credential $cred -ConnectionUri http://eurxhub02/powershell -ConfigurationName microsoft.exchange
Import-PSSession $SESJA_EX
}
$labelDateTo_Click={
#TODO: Place custom script here
}
$labelMailbox_Click={
#TODO: Place custom script here
}
$monthcalendar1_DateChanged=[System.Windows.Forms.DateRangeEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.DateRangeEventArgs]
#TODO: Place custom script here
}
$monthcalendar2_DateChanged = [System.Windows.Forms.DateRangeEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.DateRangeEventArgs]
#TODO: Place custom script here
}
$Mailbox_TextChanged={
#TODO: Place custom script here
}
$buttonRestore_Click={
$this.enabled = $false
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
$testpath = Get-mailbox $Mailbox.Text
if ($testpath)
{
$collection = $Mailbox.Text, $monthcalendar1.SelectionStart, $monthcalendar2.SelectionEnd, $combobox1.Text
$Start = $monthcalendar1.SelectionStart
$End = $monthcalendar2.SelectionEnd
$Start |Out-File c:\date.txt
Search-Mailbox $mailbox.text -SearchDumpsterOnly -TargetMailbox emea-restoreditems -SearchQuery $combobox1.Text"$start..$End" -TargetFolder Inbox
Load-ListBox $listBox $collection
}
Else
{
$empty = "Mailbox Not Found"
Load-ListBox $listBox $empty
}
#Remove-PSSession $sesja_ex
$this.enabled = $true
}
$statusbar1_PanelClick=[System.Windows.Forms.StatusBarPanelClickEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.StatusBarPanelClickEventArgs]
#TODO: Place custom script here
}
#region Control Helper Functions
function Load-ComboBox
{
Param (
[ValidateNotNull()]
[Parameter(Mandatory=$true)]
[System.Windows.Forms.ComboBox]$ComboBox,
[ValidateNotNull()]
[Parameter(Mandatory=$true)]
$Items,
[Parameter(Mandatory=$false)]
[string]$DisplayMember,
[switch]$Append
)
if(-not $Append)
{
$ComboBox.Items.Clear()
}
if($Items -is [Object[]])
{
$ComboBox.Items.AddRange($Items)
}
elseif ($Items -is [System.Collections.IEnumerable])
{
$ComboBox.BeginUpdate()
foreach($obj in $Items)
{
$ComboBox.Items.Add($obj)
}
$ComboBox.EndUpdate()
}
else
{
$ComboBox.Items.Add($Items)
}
$ComboBox.DisplayMember = $DisplayMember
}
function Load-ListBox
{
Param (
[ValidateNotNull()]
[Parameter(Mandatory=$true)]
[System.Windows.Forms.ListBox]$ListBox,
[ValidateNotNull()]
[Parameter(Mandatory=$true)]
$Items,
[Parameter(Mandatory=$false)]
[string]$DisplayMember,
[switch]$Append
)
if(-not $Append)
{
$listBox.Items.Clear()
}
if($Items -is [System.Windows.Forms.ListBox+ObjectCollection] -or $Items -is [System.Collections.ICollection])
{
$listBox.Items.AddRange($Items)
}
elseif ($Items -is [System.Collections.IEnumerable])
{
$listBox.BeginUpdate()
foreach($obj in $Items)
{
$listBox.Items.Add($obj)
}
$listBox.EndUpdate()
}
else
{
$listBox.Items.Add($Items)
}
$listBox.DisplayMember = $DisplayMember
}
#endregion
$textbox1_TextChanged={
#TODO: Place custom script here
}
$combobox1_SelectedIndexChanged={
#TODO: Place custom script here
}