Just to begin
SAPIEN Free Tools. These tools include PrimalPad, PowerShell Help, PowerShell Profile Editor and PowerRegEx. PrimalPad, the single file, color coding editor for VBScript, JScript, HTML, C, C#, SQL and PowerShell.; PowerShell Help: Help for PowerShell the way it is meant to be.; PowerShell Profile Editor is a dedicated tool for managing and editing your PowerShell profiles. Nov 22, 2020 Download Primal Form for free. Primal Form is a 3D Modeling package allowing the user to quickly build 3D objects. It sports a simple user interface inspired by Nichimen's N-World.
PrimalForms CE Consider using PowerShell Studio. The community edition of PrimalForms is no longer available. It has been replaced with PowerShell Studio. The original designer was extremely outdated and had various flaws / limitations that have been resolved and updated in PowerShell Studio. It was difficult to find some GUI Builder for me, so I've thought, that it is an good idea, to make one.Sapien Tools offers us 'Primal Tools (community edition)' for free, but then we have no permissions, to make commercial 'solutions'.
To begin my blog I though I would start by providing some various Powershell resources I find very useful.
PowerShell 2 install
- 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
File Owner Component
Active Directory Power Pack
VMware vSphere Power Pack
Reference Sites:
- http://www.scriptinganswers.com/forum2/forum_topics.asp?FID=27
Lets get right to the point… Download this great from Sapien the “PrimalForms Community Edition”. 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:
Add-Type -Assembly 'Microsoft.SqlServer.Smo' | Out-Null $bkp.Devices.AddDevice('c:tempxdeveloper.bak', 'file'); |
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.
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.
#———————————————- # Storing values to textboxes |
# 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 ( $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;
}
# 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…')
}
}
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 Community Edition and other tools – http://www.primaltools.com/downloads/communitytools/
Microsoft SQL Server SMO downloads:
Primalforms Community Edition Download
For SQL Server 2005: http://www.microsoft.com/downloads/details.aspx?FamilyID=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&displaylang=en
Primalforms Download Online
For SQL Server 2008: http://www.microsoft.com/downloads/details.aspx?FamilyId=228DE03F-3B5A-428A-923F-58A033D316E1&displaylang=en