Lets get right to the point… Download this great from Sapien the “PrimalForms Community Edition”. Warframe archwing quest not working. Its free and with a little extra work, you can add value to your scripts. In this sample I’m adding a Windows GUI to one of my demo SQL SMO script to backup a database.
Here’s the original script:
Free primalforms 2011 download. Development Tools downloads - PrimalForms 2011 by SAPIEN Technologies, Inc. And many more programs are available for instant and free download. June 7, 2011 / by David Corrales / Free Tools, PrimalForms, Software News, Windows PowerShell / No Comments PrimalForms CE Updated to Correct Version (v1.0.10) It seems we had an old version of PrimalForms Community Edition on our servers instead of the current version (v1.0.10) that was announced in this blog: PrimalForms CE Update.
Add-Type -Assembly 'Microsoft.SqlServer.Smo' | Out-Null $bkp.Devices.AddDevice('c:tempxdeveloper.bak', 'file'); $bkp.Database = 'Developer'; $bkp.Action = 'Database'; $bkp.Initialize = $true; $bkp.SQLBackup($svr); |
But, by adding a GUI interface and with some extra work, I can make it more flexible. This way I can reuse this script to backup any database from any server. Of course, keep in mind, you need use the right SMO assembly for this script to work. But, for now, we only going to use “Microsoft.SqlServer.Smo” and not the 'Microsoft.SqlServer.SmoExtended'.
I build my simple Windows GUI so I can extend my script so I can type my required parameters to do my database backup. So I use PrimalForms:
I need to create a GUI with three text fields to pass some information and a button to execute my code. During this process there will be some very basic validation. Here’s how the form will look like:
After the form is completed, then at the tool bar you click on the “Export PowerShell”:
This option will allow you to build the forms code so you can send it to three areas:
1. Sapien “PrimalScript” Editor.
2. Send to Clipboard.
3. Send to a file.
2. Send to Clipboard.
3. Send to a file.
Battleship movie tamil dubbed download. After the export, make sure you name the file. Now, with my editor, I need to look for the section of the “Button_OnClick” so I can add both the validation and the SMO backup code.
#———————————————- #Generated Event Script Blocks #———————————————- #Provide Custom Code for events specified in PrimalForms. $button1_OnClick= { #TODO: Place custom script here # Storing values to textboxes [string] $SQLServer = $textBox1.text [string] $DbName = $textBox2.text [string] $BkPathName = $textBox3.text |
# Simple textboxes validations look for empty values
if ( $SQLServer -eq '){
$Allfields = '1. '+$SQLServer
[system.Windows.forms.MessageBox]::Show($Allfields+'`r`n'+'Invalid entry or blank not allow!!')
$Pass1 = $false;}
else {
$Pass1 = $true;
}
if ( $DbName -eq '){
$Allfields = '1. '+$textBox1.text+'`r`n'+'2. '+$DbName+'`r`n'
[system.Windows.forms.MessageBox]::Show($Allfields+'`r`n'+'Invalid entry or blank not allow!!')
$Pass1 = $false;}
else {
$Pass1 = $true;
}
if ( $SQLServer -eq '){
$Allfields = '1. '+$SQLServer
[system.Windows.forms.MessageBox]::Show($Allfields+'`r`n'+'Invalid entry or blank not allow!!')
$Pass1 = $false;}
else {
$Pass1 = $true;
}
if ( $DbName -eq '){
$Allfields = '1. '+$textBox1.text+'`r`n'+'2. '+$DbName+'`r`n'
[system.Windows.forms.MessageBox]::Show($Allfields+'`r`n'+'Invalid entry or blank not allow!!')
$Pass1 = $false;}
else {
$Pass1 = $true;
}
if ( $BkPathName -eq '){
$Allfields = '1. '+$SQLServer+'`r`n'+'2. '+$DbName+'`r`n'+'3. '+$BkPathName
[system.Windows.forms.MessageBox]::Show($Allfields+'`r`n'+'Invalid entry or blank not allow!!')
$Pass1 = $false;}
else {
$Pass1 = $true;
}
$Allfields = '1. '+$SQLServer+'`r`n'+'2. '+$DbName+'`r`n'+'3. '+$BkPathName
[system.Windows.forms.MessageBox]::Show($Allfields+'`r`n'+'Invalid entry or blank not allow!!')
$Pass1 = $false;}
else {
$Pass1 = $true;
}
Sapien Primalforms Download
# If pass validation then execute the backup and verify that the backup file exist
if ($Pass1 -eq $true){
Add-Type -Assembly 'Microsoft.SqlServer.Smo' | Out-Null
#[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.Smo')
$svr = New-Object Microsoft.SqlServer.Management.Smo.server $SQLServer;
$bkp = New-Object Microsoft.SqlServer.Management.Smo.Backup;
$sqlBkupFullpathName = $BkPathName+'x'+$DbName+'.bak'
$bkp.Devices.AddDevice($sqlBkupFullpathName, 'file');
$bkp.Database = $DbName;
$bkp.Action = 'Database';
$bkp.Initialize = $true;
$bkp.SQLBackup($svr);}
if (Test-Path $sqlBkupFullpathName){
[system.Windows.forms.MessageBox]::Show('Backup $sqlBkupFullpathName is done!')
}
else {
$Allfields = '1. '+$SQLServer+'`r`n'+'2. '+$DbName+'`r`n'+'3. '+$BkPathName
[system.Windows.forms.MessageBox]::Show($Allfields+'`r`n'+'Backup Error…')
}
}
if ($Pass1 -eq $true){
Add-Type -Assembly 'Microsoft.SqlServer.Smo' | Out-Null
#[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.Smo')
$svr = New-Object Microsoft.SqlServer.Management.Smo.server $SQLServer;
$bkp = New-Object Microsoft.SqlServer.Management.Smo.Backup;
$sqlBkupFullpathName = $BkPathName+'x'+$DbName+'.bak'
$bkp.Devices.AddDevice($sqlBkupFullpathName, 'file');
$bkp.Database = $DbName;
$bkp.Action = 'Database';
$bkp.Initialize = $true;
$bkp.SQLBackup($svr);}
if (Test-Path $sqlBkupFullpathName){
[system.Windows.forms.MessageBox]::Show('Backup $sqlBkupFullpathName is done!')
}
else {
$Allfields = '1. '+$SQLServer+'`r`n'+'2. '+$DbName+'`r`n'+'3. '+$BkPathName
[system.Windows.forms.MessageBox]::Show($Allfields+'`r`n'+'Backup Error…')
}
}
Again, this script still have room evolve more and the you can keep extending the power of PowerShell with .NET framework. A simple sample is the use of “… [system.Windows.forms.MessageBox]::Show(“Test message here”) …” so that a windows message box will popup. Now, we finally completed our simple database backup GUI application.
Make sure you get SMO and PrimalForms installed and feel free to download the script: MyDbBackup.ps1
(Please rename file to a *.ps1)
For more information:
Primalforms Download Online
PrimalForms Community Edition and other tools – http://www.primaltools.com/downloads/communitytools/ Tyranid 8th edition pdf.
Microsoft SQL Server SMO downloads:
For SQL Server 2005: http://www.microsoft.com/downloads/details.aspx?FamilyID=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&displaylang=en
For SQL Server 2008: http://www.microsoft.com/downloads/details.aspx?FamilyId=228DE03F-3B5A-428A-923F-58A033D316E1&displaylang=en
Just to begin
To begin my blog I though I would start by providing some various Powershell resources I find very useful.
PowerShell 2 install
Primal Forms Download Free
- http://support.microsoft.com/kb/968929
Software
PowerGui (free PowerShell editing and development tool)
Primal Forms community edition – free GUI form developer for PowerShell [I am using the professional Edition of this very useful]
Suggested Extensions to add to Powershell
Primalforms Download App
File Owner Component
Active Directory Power Pack
VMware vSphere Power Pack
Reference Sites:
Primalforms Download Pc
- http://www.scriptinganswers.com/forum2/forum_topics.asp?FID=27