#StackBounty: #powershell #.net-framework #gui #forms Powershell GUIs (.NET forms), right click event on button

Bounty: 50

How can right click events that occur on a button be captured? I’d like to perform some action when a button receives a right click. Below is a sample form:

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$form = New-Object System.Windows.Forms.Form
$form.Size = New-Object System.Drawing.Size(400,400)
$form.StartPosition = "CenterScreen"

$button01 = New-Object System.Windows.Forms.Button
$button01.Location = New-Object System.Drawing.Size(100,100)
$button01.Size = New-Object System.Drawing.Size(100,100)
$button01.Text = "button01"
$button01.Add_Click({[System.Windows.MessageBox]::Show("Left click")})

$form.Controls.Add($button01)

$form.ShowDialog() | Out-Null

After reading some documentation, I adding this below the $button01.Add_Click line:

$button01_MouseDown=[System.Windows.Forms.MouseEventHandler]{
    $_ = [System.Windows.Forms.MouseEventArgs]
    [System.Windows.MessageBox]::Show("$_.Button")
}

When I right click on the button, no MessageBox appears.


Get this bounty!!!

#StackBounty: #windows #windows-server-2008-r2 #windows-server-2012-r2 #powershell #robocopy robocopy wierd behavior for /copyall

Bounty: 50

When I use robocopy with /copyall flag, the 1st attempt for the files will be display as “New Files” and the output will display the number of new files copied and other transfer/bytes information.

The 2nd attempt for using the same path + command will display “Modified” for the same files even though there are absolutely NO changes or any modifications at all/the output will still display “x files copied and bytes etc info”

The 3rd and subsequent attempt will then behave normally (output will not show any new/modified files transferred)

See output below

PS C:Usersadministrator.SG-EQUINIX> robocopy B:MSSQLTesttest1 \sqldr1BackupTest /copyall

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------------------

  Started : Monday, 15 May 2017 12:37:33 AM
   Source : B:MSSQLTesttest1
     Dest : \sqldr1BackupTest

    Files : *.*

  Options : *.* /COPYALL /R:1000000 /W:30

------------------------------------------------------------------------------

                           2    B:MSSQLTesttest1
100%        **New File**              34.8 m        IBXX_backup_2017_04_19_173001_8474121 - Copy.trn
100%        **New File**              34.8 m        nn.trn

------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         0         0         0         0         0
   Files :         2         2         0         0         0         0
   Bytes :   69.65 m   69.65 m         0         0         0         0
   Times :   0:00:15   0:00:15                       0:00:00   0:00:00


   Speed :             4723113 Bytes/sec.
   Speed :             270.258 MegaBytes/min.
   Ended : Monday, 15 May 2017 12:37:49 AM

PS C:Usersadministrator.SG-EQUINIX> robocopy B:MSSQLTesttest1 \sqldr1BackupTest /copyall

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------------------

  Started : Monday, 15 May 2017 12:38:11 AM
   Source : B:MSSQLTesttest1
     Dest : \sqldr1BackupTest

    Files : *.*

  Options : *.* /COPYALL /R:1000000 /W:30

------------------------------------------------------------------------------

                           2    B:MSSQLTesttest1
            **Modified**              34.8 m        IBXX_backup_2017_04_19_173001_8474121 - Copy.trn
            **Modified**              34.8 m        nn.trn

------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         0         0         0         0         0
   Files :         2         2         0         0         0         0
   Bytes :   69.65 m   69.65 m         0         0         0         0
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00


   Speed :           2282592000 Bytes/sec.
   Speed :           130610.961 MegaBytes/min.
   Ended : Monday, 15 May 2017 12:38:11 AM

Anyone has any idea why ?


Get this bounty!!!

#StackBounty: #powershell #amazon-web-services #continuous-integration #elastic-beanstalk #devops AWS Elasticbeanstalk ebextensions ser…

Bounty: 200

I’ve got a elasticbeanstalk environment that needs to run a powershell script and restart before the application is deployed. According to the documentation this is supported as per the documentation

If the system requires a reboot after the command completes, the system reboots after the specified number of seconds elapses. If the system reboots as a result of a command, Elastic Beanstalk will recover to the point after the command in the configuration file. The default value is 60 seconds. You can also specify forever, but the system must reboot before you can run another command.

However when I add a reboot command to a ebextensions .config file I get the following exception from elasticbeanstalk

Error occurred during build: [Errno 4] Interrupted function call

The logs on the server after it has rebooted show that the command was executed so I assume the error is caused by a restart during the app deploy stage.

If I remove the restart command, deploy, wait for it to be ready then trigger a restart manually it works fine. But this is obviously not acceptable.

I’ve looked into the deployment hooks file system approach but that doesn’t work either, and seems unessesary given it sounds like it should support this requirement out of the box.

Does anybody have any ideas?


Get this bounty!!!

#StackBounty: #sql-server-2012 #c# #powershell #smo Why can't C# SMO see extended properties on a column but Powershell SMO can?

Bounty: 200

I am attempting to read extended properties on tables and columns in a winforms C# application. I am using SQL Server SMO to do so. When I execute the application it does not see the extended properties, but when I read the extended properties using PowerShell, it does see the extended properties.

The C# code:

var x = col.ExtendedProperties.Count;
var NPI = col.ExtendedProperties["NPI"].Value;
bool npi = bool.Parse(NPI.ToString());

The PowerShell code:

Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $env:COMPUTERNAME
$server.Databases["<db name>"].Tables["<table name>"].Columns["<column name>"].ExtendedProperties | Select Name, Value, State

I have checked and both Visual Studio and PowerShell are using the same version of SMO (11.0.0.0). When I execute the C# code the col.ExtendedProperties.Count = 0, but when I execute the PowerShell code I get:

Name Value    State
---- -----    -----
NPI  False Existing

Does anyone have any ideas as to why this could be happening?


Get this bounty!!!

#StackBounty: #sql-server-2012 #c# #powershell #smo Why can't C# SMO see extended properties on a column but Powershell SMO can?

Bounty: 200

I am attempting to read extended properties on tables and columns in a winforms C# application. I am using SQL Server SMO to do so. When I execute the application it does not see the extended properties, but when I read the extended properties using PowerShell, it does see the extended properties.

The C# code:

var x = col.ExtendedProperties.Count;
var NPI = col.ExtendedProperties["NPI"].Value;
bool npi = bool.Parse(NPI.ToString());

The PowerShell code:

Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $env:COMPUTERNAME
$server.Databases["<db name>"].Tables["<table name>"].Columns["<column name>"].ExtendedProperties | Select Name, Value, State

I have checked and both Visual Studio and PowerShell are using the same version of SMO (11.0.0.0). When I execute the C# code the col.ExtendedProperties.Count = 0, but when I execute the PowerShell code I get:

Name Value    State
---- -----    -----
NPI  False Existing

Does anyone have any ideas as to why this could be happening?


Get this bounty!!!

#StackBounty: #sql-server-2012 #c# #powershell #smo Why can't C# SMO see extended properties on a column but Powershell SMO can?

Bounty: 200

I am attempting to read extended properties on tables and columns in a winforms C# application. I am using SQL Server SMO to do so. When I execute the application it does not see the extended properties, but when I read the extended properties using PowerShell, it does see the extended properties.

The C# code:

var x = col.ExtendedProperties.Count;
var NPI = col.ExtendedProperties["NPI"].Value;
bool npi = bool.Parse(NPI.ToString());

The PowerShell code:

Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $env:COMPUTERNAME
$server.Databases["<db name>"].Tables["<table name>"].Columns["<column name>"].ExtendedProperties | Select Name, Value, State

I have checked and both Visual Studio and PowerShell are using the same version of SMO (11.0.0.0). When I execute the C# code the col.ExtendedProperties.Count = 0, but when I execute the PowerShell code I get:

Name Value    State
---- -----    -----
NPI  False Existing

Does anyone have any ideas as to why this could be happening?


Get this bounty!!!

#StackBounty: #sql-server-2012 #c# #powershell #smo Why can't C# SMO see extended properties on a column but Powershell SMO can?

Bounty: 200

I am attempting to read extended properties on tables and columns in a winforms C# application. I am using SQL Server SMO to do so. When I execute the application it does not see the extended properties, but when I read the extended properties using PowerShell, it does see the extended properties.

The C# code:

var x = col.ExtendedProperties.Count;
var NPI = col.ExtendedProperties["NPI"].Value;
bool npi = bool.Parse(NPI.ToString());

The PowerShell code:

Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $env:COMPUTERNAME
$server.Databases["<db name>"].Tables["<table name>"].Columns["<column name>"].ExtendedProperties | Select Name, Value, State

I have checked and both Visual Studio and PowerShell are using the same version of SMO (11.0.0.0). When I execute the C# code the col.ExtendedProperties.Count = 0, but when I execute the PowerShell code I get:

Name Value    State
---- -----    -----
NPI  False Existing

Does anyone have any ideas as to why this could be happening?


Get this bounty!!!

#StackBounty: #sql-server-2012 #c# #powershell #smo Why can't C# SMO see extended properties on a column but Powershell SMO can?

Bounty: 200

I am attempting to read extended properties on tables and columns in a winforms C# application. I am using SQL Server SMO to do so. When I execute the application it does not see the extended properties, but when I read the extended properties using PowerShell, it does see the extended properties.

The C# code:

var x = col.ExtendedProperties.Count;
var NPI = col.ExtendedProperties["NPI"].Value;
bool npi = bool.Parse(NPI.ToString());

The PowerShell code:

Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $env:COMPUTERNAME
$server.Databases["<db name>"].Tables["<table name>"].Columns["<column name>"].ExtendedProperties | Select Name, Value, State

I have checked and both Visual Studio and PowerShell are using the same version of SMO (11.0.0.0). When I execute the C# code the col.ExtendedProperties.Count = 0, but when I execute the PowerShell code I get:

Name Value    State
---- -----    -----
NPI  False Existing

Does anyone have any ideas as to why this could be happening?


Get this bounty!!!

#StackBounty: #sql-server-2012 #c# #powershell #smo Why can't C# SMO see extended properties on a column but Powershell SMO can?

Bounty: 200

I am attempting to read extended properties on tables and columns in a winforms C# application. I am using SQL Server SMO to do so. When I execute the application it does not see the extended properties, but when I read the extended properties using PowerShell, it does see the extended properties.

The C# code:

var x = col.ExtendedProperties.Count;
var NPI = col.ExtendedProperties["NPI"].Value;
bool npi = bool.Parse(NPI.ToString());

The PowerShell code:

Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $env:COMPUTERNAME
$server.Databases["<db name>"].Tables["<table name>"].Columns["<column name>"].ExtendedProperties | Select Name, Value, State

I have checked and both Visual Studio and PowerShell are using the same version of SMO (11.0.0.0). When I execute the C# code the col.ExtendedProperties.Count = 0, but when I execute the PowerShell code I get:

Name Value    State
---- -----    -----
NPI  False Existing

Does anyone have any ideas as to why this could be happening?


Get this bounty!!!

#StackBounty: #sql-server-2012 #c# #powershell #smo Why can't C# SMO see extended properties on a column but Powershell SMO can?

Bounty: 200

I am attempting to read extended properties on tables and columns in a winforms C# application. I am using SQL Server SMO to do so. When I execute the application it does not see the extended properties, but when I read the extended properties using PowerShell, it does see the extended properties.

The C# code:

var x = col.ExtendedProperties.Count;
var NPI = col.ExtendedProperties["NPI"].Value;
bool npi = bool.Parse(NPI.ToString());

The PowerShell code:

Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $env:COMPUTERNAME
$server.Databases["<db name>"].Tables["<table name>"].Columns["<column name>"].ExtendedProperties | Select Name, Value, State

I have checked and both Visual Studio and PowerShell are using the same version of SMO (11.0.0.0). When I execute the C# code the col.ExtendedProperties.Count = 0, but when I execute the PowerShell code I get:

Name Value    State
---- -----    -----
NPI  False Existing

Does anyone have any ideas as to why this could be happening?


Get this bounty!!!