opening windows form in powershell - winforms

I am attempting to create a powershell script that will ask the user to restart the computer after a certain number of days. I'm building the script in VS 2012, and would like the script to open a windows form I'm building in the project.
$lastboot = (Get-CimInstance -Class win32_operatingsystem).lastbootuptime
$cutoff = (Get-Date).AddDays(-30)
If(($lastboot) -le ($cutoff)) {
Write-Output "Reboot Required"
}
Else{
Write-Output "No Reboot Required at this time"
}
Any advice on how I can get the script to call up the restart windows form (restartForm.cs).

Why don't you build the GUI in powershell?
Add-Type -AssemblyName System.Windows.Forms
$form = New-Object system.Windows.Forms.Form
$form.Text = "My Fancy Windows Form"
[void]$form.ShowDialog()
$form.Dispose()

FYI... There are tools you can add to VS to help with this.
Just add PowerShell to you VS project and add to your existing project. You just download and use the PowerShell VS integration add-in. Use your form designer.
PowerShell Windows Forms Designer Demo in Visual Studio
https://www.youtube.com/watch?v=418sH2lcZ1w
-Updated- https://www.youtube.com/watch?v=q4CsFblKotc&list=UUIrhSHyw-ySF4eQFkt6fQSA&index=10
PowerShell Tools for Visual Studio – Now Available
Over the past few months we (at Microsoft) have been working with Adam
Driscoll, a Microsoft MVP who started this extension back in 2013.
Adam released it as open source on GitHub and a few months ago
Microsoft created a fork to join community and contribute to the
project.
https://blogs.msdn.microsoft.com/powershell/2015/04/19/powershell-tools-for-visual-studio-now-available
PowerShell Tools for Visual Studio 2012
PowerShell Tools for Visual Studio adds language support for
PowerShell in Visual Studio 2012.
https://marketplace.visualstudio.com/items?itemName=AdamRDriscoll.PowerShellToolsforVisualStudio2012
PowerShell Pro Tools for Visual Studio PowerShell Pro Tools supports
Visual Studio Community. Get a full featured PowerShell IDE with UI
development and packaging
https://poshtools.com/powershell-pro-tools-for-visual-studio

Related

Is it possible to change the background color of the Object Explorer and the Result Menu in SQL Server Management Studio 2017

Pretty much what the title says. Just started learning SQL server. I found how to 'unlock' the dark theme and how to change the fonts and sizes but i still can't change the color in the Object Explorer and the Result Menu in SQL Server Management Studio 2017. Is it possible that this is all we got till now... Cause it is hard for me to believe that there is no working full dark theme for SQL Server Management Studio 2017 or the possibility to change it manualy. Any help would be much appreciated. Also is there another IDE or editor for SQL server 2017 other than SQL Server Management Studio 2017, like there are a LOT diffirent editors for programing languages like Sublime, NotePad++, VS Code etc...
According to https://datamajor.net/ssms_darktheme/ and other sources
Dark theme in SSMS is incomplete and it isn't clear whether it will ever be completed and officially included.
Meanwhile it is possible to work with SQL Server using IDEs that have Dark theme:
Azure Data Studio (by Microsoft free)
Visual Studio Code (by Microsoft free)
Visual Studio Express (by Microsoft free)
dbForge Studio (by DevArt paid product)
run powershell as run as adminstrator and run this code to change bg to dark mode :
powershell -Command "(gc 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.pkgundef') -replace '\[\`$RootKey\`$\\Themes\\{1ded0138-47ce-435e-84ef-9ec1f439b749}\]', '//[`$RootKey`$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}]' | Out-File 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.pkgundef'"

Powershell Form in Visual Studio

I am struggling with GUI for powershell in visual studio 2015 enterprise.
Problem is:
I want to build gui for powershell scripts in visual studio. I know how to do it in Powershell ISE however it takes a lot of time to build forms through scripts. I do not want to download Sapien Powershell Studio or Powershell Studio for this purpose. This version has built-in powershell projects, namely: Powershell Module Project and Powershell Script Project. However, once you choose this type of project you are unable to add windows forms. I know it is possible, just look at the video from youtube below:
https://www.youtube.com/watch?v=q4CsFblKotc&list=UUIrhSHyw-ySF4eQFkt6fQSA&index=10
As you can see guy in the video has ability to add Powershell Form to the project. I cannot do it as the only options I have are:
Powershell Script,
Powershell Test,
Powershell Script Data File,
Powershell Script Module.
I will also add that I do not want to use WPF project for this.
Does anyone know how to enable Powershell Forms in Visual Stuido? Thanks in advance!!
You will need the following:
[**Visual Studio 2017 (Any edition, Community edition)**][1]
**[PowerShell Tools for Visual Studio 2017][1]**
SOURCE: https://wandering.life/building-windows-forms-powershell-visual-studio-2017/

How to create set up files for wpf application

How can I create set up file for WPF application ? I'm new to WPF applications and I don't have any idea about initializing this.Please help me !!
I advise you to use InnoSetup. It's a powerfull tools to make setup-wizard for all projects. You can create it easyly. And more features are available with it (icons file, registry management, associate file extension with application, desktop and start menu windows entry, and much more...)
I suggest you to go through below link if you are using VS 2010 and above-
CREATE SETUP AND DEPLOYMENT OF WPF APPLICATION STEP BY STEP WITH VISUAL STUDIO 2012
You need InstallShield packaging software to after Visual Studio 2008.
It will create a template to create deployment project, but you can
get the Visual Studio Installer Projects in VS 2010 and above , you
need to install the Visual Studio Installer Extension from the Visual
Studio Extension Gallery - Microsoft Visual Studio Installer
Projects
If you are using VS 2008 then it already have template to create setup project your WPF application. Just follow the below link to know that How use Setup Project..
Create Setup and Deployment of WPF Application Step by Step
#Hana's answer showing screenshot of the Setup Project, which is used in the VS 2008 to create the deployment package.
References:
Create an application setup in visual studio 2013
Visual Studio 2013 Installer Projects – Hello World Installer
Using VS 2008:
Add a Setup and Deployment project to the Solution
As soon as you add the project it opens the File Explorer view.
add Program File's Folder to our Setup project
add Primary output and other dependencies to Application Folder.
Select as displayed above.
Now we would add A folder to the Program Files Folder.
Now add the same as you did for the Application Folder.
add a Shortcut to User's Desktop.
Rebuild the Solution and then rebuild the Setup project.
Full help is here

How can I create an installer (msi) in visual studio express 2010?

I have just finished creating a wpf application in visual studio express C# and need to create an installer file. This is going on just a couple of machines because it is a personal program for me. I have looked into Advanced Installer using the simple method but cannot figure out how to do that or if it can even create a wpf installer. I have also tried WIX with the same results.
Any tips for doing this?
Before I start using WiX I worked with NSIS and HM NIS Edit which has a wizard to create simple installers.
Perhaps it can help you for your purposes.

Visual Studio 2008 Xaml Editor not working / disappeared

When I start up VS 2008 to work on a WPF / Silverlight App and open a XAML or XML file the XAML / XML editor is no longer working. The designer does not show up and intellisense is unavailable. It basically looks like a text file has been opened.
Try running the following command.
"%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\ide\devenv" /resetSkipPkgs
If that doesn't work try repairing the Visual Studio Install
Start -> Control Panel
Add Remove Programs
Select VS
Choose repair
The designer for XAML is awful. Do yourself a favour and set your XAML files to open in the code viewer instead; they'll load quicker and you won't have to deal with the designer's flakiness.
However, to fix the intellisense, just re-register TextMgrP.dll using regsvr32 as indicated here.
I've seen this problem before, running this command should fix it :
Devenv.exe /ResetSkipPkgs
If you right click the file, select "Open With", and then choose "Windows Presentation Foundation Designer", does that work? If so, most likely the default editor for .xaml files has changed. You can reset this back to the designer by pressing "Set as Default" when the designer you want is selected in the list in the Open With dialog.
It looks like there is an XML package that was previously not loaded, see other question here;
Visual Studio 2008 XML Editor Disappeared
Also, there is an answer on the Silverlight forums that describes using the "devenv /setup" command that can be found in (VS2008InstallationDirectory)\IDE.
AHHHHHHHHHHHHHHH!!!!!! It finally worked!!!!! Only after a week of pulling my hair out. I had multiple issues.
Xaml editor and add DataSource Wizard and other things would not work with VS 2008.
Tried to install SP1. It would not let me because Office Suite 2007 was in the middle of an SP1 update and would not finish.
Un-installed Microsoft office and reinstalled and service packed.
Tried devenv /setp & devenv /resetskippkgs to no avail.
Finally service packed VS2008.
Retried the devenv /setp & devenv /resetskippkgs twice and voila!! It worked.
Thanks a bunch.
i had similar problems when i installed VS2008 Professional over an existing VS2008 Express edition. Suddenly my XAML designer stopped working . i got failed loading the XAML dll error.
So i just uninstalled all VS Express stuff and then installed VS 2008 SP1 fixed all things.
try link below for VS 2008 SP1.
http://www.microsoft.com/downloads/details.aspx?FamilyId=27673C47-B3B5-4C67-BD99-84E525B5CE61&displaylang=en

Resources