How to display an .rtf file in a Powershell RichTextBox - powershell

I want to display the content of an RTF file in a Powershell RichTextBox.
I am trying to make a kind of custom EULA, and the easiest way to do it would be to write the content in an RTF file and then have it display in a RichTextBox on my form, so the user has to click a checkbox to accept it.
(I'm sure this sits between ServerFault and StackOverflow, but I'm guessing the DotNet gurus on here will know best. ;-) )
Cheers,
Ben

In case anyone else happens upon this wondering where the PowerShell RichTextBox control came from it's a reference to the one in System.Windows.Forms. Here's the code with prerequisite build up:
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$rtb = New-Object System.Windows.Forms.RichTextBox
$rtb.LoadFile($path)

OK - that was easy. Should have got my lazy ass on Google a bit more before posting. Used RichTextFile.Loadfile(c:\myfile.rtf) and it worked a treat.

Related

Powershell GUI displaying text file

I have an app I developed and made a GUI for. In one of the directories I have a log.txt file.
I have a strip menu option meant to display the log file to the user. I'm wondering what would be the best method for displaying this log file?
Right now I'm just using
notepad log.txt
Which technically works but doesn't seem to be the most efficient or professional way.
I'm guessing it is probably just opening another form with a large read only text box but on the off chance someone has something that works even better I'll appreciate the suggestion.
Info displayed in log is:
Version
Description
Date

SSRS - Rendering to PDF and reupload

is it possible to render/save a SSRS report as a PDF and upload the PDF-file on the server in a second step? I would prefer Powershell webservices?
Thank you in advance.
You are not showing your code, or what you've even searched for. Folks here don't like it when you don't show any effort, and will quickly downvote your post or vote to close and point you here: https://stackoverflow.com/help/how-to-ask. Closing by telling you that StackOverflow is not a free script writing service.
However, since you are very new here, I'll provide you this, this time.
I am not sure what this is... 'Powershell webservices', but maybe you meant PowerShell Web Access, and if so, that is not what it is for. Saving output to PDF using PowerShell is a real common thing, and well documented all over the web and that just requires a simple search for that content/samples:
See the PowerShell cmdlet
Out-Printer
Just choose a PDF printer installed on the target.
Sending PowerShell Results to PDF (Part 1 - 3)
https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/sending-powershell-results-to-pdf-part-1
https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/sending-powershell-results-to-pdf-part-2
https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/sending-powershell-results-to-pdf-part-3
The author provides samples in each post listed...
Snippet from part 3:
function Out-PDFFile
{
param
(
$Path = "$env:temp\results.pdf",
[Switch]
$Open
)
...
}
Creating PDF files using PowerShell
Sometimes, you may want your scripts to produce output for management
in a format other than plain text or Excel files (CSV). Thanks to
various .NET PDF creation libraries, it is relatively simple to create
PDF reports using PowerShell.
Directly from Microsoft Docs site.
Automate SSRS Report Generation using PowerShell
This blog post is tested on SQL Server 2014 and PowerShell V5.
...
In this blog post I will focus on generating PDF reports via scripting. Let's tackle this piece by piece first, and we'll put
everything in a nice little script at the end of the post.
...
As far as uploading files, that is what the PowerShell web cmdlets are for.
Invoke-WebRequest
Invoke-RestMethod
or the native .Net namespace
WebClient.UploadFile Method
... so as for this... 'Powershell webservices', I am going to assume this is what you meant.

Powershell Help, the code i have sends a email out to people, need to save a the data of the code but not as a text file

I am new to powershell and need some help. I have a code which runs everyday and sends an email out to people regarding the server status and other details. What i need to do is save that file as maybe an output file or something so if the customer wants can go in to powershell type in the script command and it comes up with the information thats on the email
Is there a way to do this. This cant be a text file. Has to be something u can type and the data comes up?
please help, thanks in advance
Os
Without code the only definite answer I can give you is using the Out-File command. I do not see why it can't be a txt file (because it's just an email)since data can come up and be typed. You can always Out-File to excel or csv, it really all depends on what you're trying to ask.

Automate Outlook first time opening

I wanted to configure a script that would basically take the opening Outlook 2010 for the first time dialog and accept the defaults. We have an exchange server that is currently running that populates the first time fields with the user's AD information. Basically I wanted to write a script in powershell that would accept the default values that AD has filled in and complete the install. Once the install is complete Outlook will set up a copy of the user's mailbox and all of their mail will be pulled down to the computer.
I have been trying and trying in powershell to accomplish the acceptance of defaults to no avail. Is there any possible way to link a powershell script with outlook and have it accept GUI dialogs?
I have not written any code to do this other than a little initialization script in powershell. I am also a powershell newbie so I know enough to create a com object and call that object so that it can open Outlook but that is as far as I can go.
Can someone please give me some help? Here is what I have but it really doesn't work that well:
$mail = new-object -com Outlook.Application
$namespace = $mail.GetNamespace("MAPI")
$folder = $namespace.GetDefaultFolder("olFolderInbox")
$explorer = $folder.GetExplorer()
$explorer.Display()
I'm not sure how far you've gotten with PowerShell, but review this link.
Consider other Windows GUI scripting engines, they should solve this problem pretty easily - more easily than PowerShell scripting.
Try:
AutoHotkey
AutoIt
I ended up using the WASP snap-in at http://wasp.codeplex.com/. It allows UI automation by finding widows and sending commands to those windows. It is easy to use and makes tasks like mine a lot easier. It is only a 32 bit .dll but it works for Powershell >= 2.0. Thank you all for your helpful comments.

Is there any way to parse Microsoft excel in iPhone?

I want to parse an excel sheet and have to display the content in table view. Suggestions please.
The easiest way is to save your excel file as a text file with tab delimiters. This way its straight forward. In case you like to do some "intelligent" parsing - you may just take a look at one of these many parser tutorials for the iPhone. I am sure, you will be able to build on these sample quite easily.