Hi everybody,
My goal is that i can run a Powershell script which then creates a shortcut of the Website which is opened at the moment. I know it's no problem to create a shortcut from a path or document, but now i habe to do it from a website.
First of all, is that even possible? If yes, do i need a add on or does it just work with Powershell?
I haven't found anything usefull in the internet. I'm not really skilled with Powershell so that's why i'm not sure if that is even possible.
I'm thankful at any hint.
Greetings.
Yehellow
I don't know how to do it in powershell, but there is another programming language called AutoIt. It's made for automations exactly like this. Just download it from the AutoIt page.
Here is the code that worked for me. If you need to inport it into your powershell script just compile the AutoIt code into an .exe, run it with powershell and read the output from a .txt file.
Syntax:
#include <IE.au3>
$oIE = _IEAttach("*TITLE OF THE PAGE*")
$url = _IEPropertyGet($oIE, "locationurl")
Example:
#include <IE.au3>
#include <MsgBoxConstants.au3>
$oIE = _IEAttach("Google")
$url = _IEPropertyGet($oIE, "locationurl")
MsgBox(0,$url,$url)
As far as i know it only works for IE. Sorry for not having a solutoin for Powershell.
Related
in my powershell script a lot of items are getting printed in the console.
I want to copy them and validate a data is present or not. Any way I can do it?
I am yet to get any solution for this. thank you in advance
One Way to record everything thats going on with your Script is Powershell Transcript
Or you can just Copy the Output from your Console to a Text file in Notepad++ or something like that...
But to be honest I don't quite understand what you are trying to achieve with that, wouldn't be the goal with a script that you don't have to check something like that?
My suggestion would be that you look for a way to validate anything you need within your Script, and maybe implement some sort of Logging to have the Option to review it when something has gone wrong...
I used $variable = command and it is working.
if your case is to validate your logs I suggest saving the logs into a file and then validating them and don't use the console for that purpose.
if you still want to copy them from the console try this: Copy text from a Windows CMD window to clipboard
In your situation, i would use Start-Transcript into a log file.
And then get information from the log file using filters.
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.
I am new to Powershell and after having a few ideas and deciding to tinker around a bit I noticed that I can write a script in Poswershell that will make a search request on a search engine that I specify.
The issue is I am not sure exactly how it works. How is this script able to know how to open my web browser when all I did was specify a string filled with an address?
I have searched up other posts and have not found anything close to what I am asking (I believe).
Here is my source and I will also add an image.
[String]$SearchFor = "bing rewards"
$Query = "http://www.bing.com/search?q=$SearchFor"
Start $Query
Thank you all for your help.
Read help on start-process
https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.management/start-process
If you specify a non-executable file, Start-Process starts the program
that is associated with the file, similar to the Invoke-Item cmdlet.
So if I would have a TXT File in C:\test.txt and run
start-process c:\test.txt
It would open my default application assiociated with that file. On my PC it would open test.txt in notepad.
Hope that makes it clear now.
It simply uses the default application to open URLs on your desktop i.e. your default Internet browser.
Same behavior if you paste the URL (without variables) in your Start > Run box.
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.
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.