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.
Related
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 Noob here.
I have a basic Powershell script that requests user's credentials and then starts MMC programs for remote administration (example: dsa.msc). No issues with the script.
However, I am not happy with the size of the "Windows Powershell Credentials Request" window. I am using Get-Credential "$env:USERDNSDOMAIN\" but our domain name is pretty long.
What I would like:
(Preferred) Have the the domain name gathered in the script ($env:USERDNSDOMAIN) and the when the user is prompted for credentials; the username field will be empty and the user will only need to type their AD username. OR
Have the credentials be collected WITHIN the powershell window so there is enough room
Any assistance is appreciated. Thank you in advance.
You cannot change the default modal dialog/UI in Windows. If you want this control, you can write your own Winfomr/WPF GUI. deploy that for users to execute.
If you have not done this, use this free tool (though WinForm only - for now)...
Online Powershell Form Designer
...for your first effort at GUI design, but read up on GUI design (Winform and WPF) to know what this is about and the other steps you are going to need to do, to get it to do anything.
Youtube -
'PowerShell gui design'
As for your two bullet points. You are halfway there. Just do this:
Get-Credential "$env:USERDNSDOMAIN\$env:USERNAME"
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.
Here's what I would like to archieve:
I would like to create a basic VBA application in order for people to input values which are eventually ran in a Powershell instance.
In order to so this , I would either like the program to output the values in the form in a prefined script and then the user manualy enters this in powershell or I would like the user to input their office 365 credentials prior to filling in the form and for the application to run the script after the user has filled in the values.
Im wondering which would be best to start work on?
Any help would be greatly appreciated
Thanks
Not sure of the specific details, but most of the time these sort of projects are best done completely in powershell. Consider the following:
$Creds = Get-Credential -Message 'Office 365 Login'
Users get a prompt to enter their credentials in an 'official' Windows dialog box, and you get the creds in powershell form automatically. Your form can be created entirely in powershell using the .NET framework, or even WPF I believe, whichever suits your fancy.
I am trying to implement in windows scripting host the same function as windows Send To/Mail Recipient does. Did not find anything usefull on google except steps to instantiate Outlook.Application and directly calling its methods.
I need to go the same path as windows do, as there is a mix of Outlook and Lotus Notes installed, I don't see it good to perform some sort of testing and deciding which object to talk to...
What I have found is that the actual work is done by sendmail.dll, there is a handler defined in registry under HKEY_CLASSES_ROOT\CLSID\{9E56BE60-C50F-11CF-9A2C-00A0C90A90CE}. I would like either to use this dll somehow or to simulate the same steps it does.
Thanks for your input.
I found one item on CodeProject from 2003 that might be relevant.
The contents of the sent to menu in Windows is a bunch of files (usually links) in the C:\Documents and Settings\username\SendTo folder. You need to add your script - or a link to it - there.
For your script you could check if certain registry keys exist to detect Outlook and Lotus Notes.
Or if you don't care if the message shows up in sent items, just use CDOSYS.NewMail to send the message directly to the SMTP-server.
CDOSYS documentation