Sign in to follow this  
Followers 0
ptrex

Powershell - COM

28 posts in this topic

#1 ·  Posted (edited)

Powershell - COM

Many Windows Business Application are now only supporting Powershell, as a scripting environment.

Like MS Exchange / SharePoint / Active Directory / MS SQL / etc.

This makes Au3 a handicapped scripting environment for administrators to work with.

But hold on !

Since 2008 Sapien Technologies has released a Powershell COM component named ActiveXPoSH, that makes the bridge between all

Download here http://www.sapien.com/blog/2008/06/25/activexposh-is-now-a-free-download/

First register an account before getting the download access http://www.sapien.com/auth

Why would you need Au3 to join PS1 ?

Well it is a hell lot easier to create GUI's in AU3 than it is in PS1, so let's marry the 2.

Here's an example script translated from there help file to AU3

;**************************************************************************
; Copyright (c) SAPIEN Technologies, Inc. All rights reserved
; This file is part of the PrimalScript 2007 Code Samples.
;
; File: ActiveXposh.vbs
;
; Comments:
;
; Disclaimer: This source code is intended only as a supplement to
;   SAPIEN Development Tools and/or on-line documentation.
;   See these other materials for detailed information
;   regarding SAPIEN code samples.
;
; THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
; PARTICULAR PURPOSE.
;**************************************************************************

#AutoIt3Wrapper_UseX64=N

Dim $ActiveXPosh

Const $OUTPUT_CONSOLE = 0
Const $OUTPUT_WINDOW = 1
Const $OUTPUT_BUFFER = 2

Func CreateActiveXPosh()
Dim $success

; Create the PowerShell connector object
$ActiveXPosh = ObjCreate("SAPIEN.ActiveXPoSH")
$success = $ActiveXPosh.Init(False) ;Do not load profiles
If $success <> 0 then
Consolewrite( "Init failed" & @CR)
endif
If $ActiveXPosh.IsPowerShellInstalled Then
Consolewrite( "Ready to run PowerShell commands" & @CR)
Else
Consolewrite( "PowerShell not installed" & @CR)
EndIf
; Set the output mode
$ActiveXPosh.OutputMode = $OUTPUT_CONSOLE
EndFunc


Func DownloadFile($URL,$Destination)
Local $Return
Dim $Command
Dim $FSO

;Download a file with PowerShell
$ActiveXPosh.Execute("$Client = new-object System.Net.WebClient")
;Note that variables are preserved between calls
; Construct a $Command
$Command = "$Client.DownloadFile('" & $URL & "','" & $Destination & "')"
ConsoleWrite ("Downloading ..." & @CR)
$ActiveXPosh.Execute($Command)

$FSO = ObjCreate("Scripting.FileSystemObject")
If $FSO.FileExists($Destination) Then
ConsoleWrite ("File transfer complete" & @CR)
Else
ConsoleWrite ("File Transfer failed" & @CR)
EndIf
Return $Return
EndFunc

Func ListServices()
Dim $outtext
; Set the $OUTPUT mode to $BUFFER
$ActiveXPosh.OutputMode = $OUTPUT_BUFFER
$ActiveXPosh.Execute("Get-WmiObject -class Win32_Service | Format-Table -property Name, State")

; Get the $OUTPUT line by line and add it to a variable
For $str In $ActiveXPosh.OUTPUT()
$outtext = $outtext & $str
$outtext = $outtext & @CRLF
Next

; Alternatively you can get the $OUTPUT as a single String
; $outtext = $ActiveXPosh.OutputString

ConsoleWrite ($outtext & @CR)
$ActiveXPosh.ClearOutput() ; Empty the $OUTPUT $BUFFER
EndFunc

; Create the actual Object
CreateActiveXPosh()

$Status = $ActiveXPosh.GetValue("(Get-Service UPS).Status")
if($Status = "Stopped") then
ConsoleWrite ("UPS Service is stopped" & @CR)
else
ConsoleWrite ("UPS Service is " & $Status & @CR)
EndIf


; List all running processes using PowerShell
$ActiveXPosh.Execute("Get-Process")

; Check if WinWord is running using PowerShell
if $ActiveXPosh.Eval("get-process winword") = 1 Then
ConsoleWrite ("Microsoft Word is running" & @CR)
Else
ConsoleWrite ("Microsoft Word is not running" & @CR)
EndIf

DownloadFile ("[url="http://izzy.org/scripts/PowerShell/activexposh.pdf","C:\Temp\activexposh.pdf"]http://izzy.org/scripts/PowerShell/activexposh.pdf","C:\Temp\activexposh.pdf[/url]")

; Use ListServices to show all services in this machine using PowerShell()
ListServices()

ConsoleWrite ("Version " & $ActiveXPosh.GetValue("$PSHOME") & @CR)

$ActiveXPosh = ""

Example how to load a PS1 command file

#AutoIt3Wrapper_UseX64=N

Dim $ActiveXPosh

Const $OUTPUT_CONSOLE = 0
Const $OUTPUT_WINDOW = 1
Const $OUTPUT_BUFFER = 2

Func CreateActiveXPosh()
 Local $success
 ; Create the PowerShell connector object
 $ActiveXPosh = ObjCreate("SAPIEN.ActiveXPoSH")
 $success = $ActiveXPosh.Init(False) ;Do not load profiles
 If $success <> 0 then
  Consolewrite( "Init failed" & @CR)
 endif
 If $ActiveXPosh.IsPowerShellInstalled Then
  Consolewrite( "Ready to run PowerShell commands" & @CR & @CR)
 Else
  Consolewrite( "PowerShell not installed" & @CR & @CR)
 EndIf
 ; Set the output mode
 $ActiveXPosh.OutputMode = $OUTPUT_CONSOLE
 $ActiveXPosh.OutputWidth = 250
EndFunc

; Create the actual Object
CreateActiveXPosh()

$PS1 = FileOpenDialog("Open PS1 Script", @ScriptDir & "\", "PS Scripts (*.ps1)")
PowerShell_Script($PS1)

Func PowerShell_Script($hPSFile)
$file = FileOpen($hPSFile, 0) ; Open read only
 If $file = -1 Then
  MsgBox(0, "Error", "Unable to open file.")
  Exit
 EndIf

Local $sCmd

While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
 $sCmd &= $line & @CRLF
Wend
 ; ConsoleWrite("Line read: " & @CRLF & $sCmd & @CRLF)

FileClose($file)
 ExecuteCMD($sCmd)
EndFunc


Func ExecuteCMD($sPSCmd)
 Dim $outtext
 ; Set the $OUTPUT mode to $BUFFER
 $ActiveXPosh.OutputMode = $OUTPUT_BUFFER
 $ActiveXPosh.Execute($sPSCmd)

 ; Get the $OUTPUT line by line and add it to a variable
 For $str In $ActiveXPosh.OUTPUT()
   $outtext =  $outtext & $str
  $outtext =  $outtext & @CRLF
 Next

 ; Alternatively you can get the $OUTPUT as a single String
; $outtext = $ActiveXPosh.OutputString
 ConsoleWrite ($outtext & @CR)

 $ActiveXPosh.ClearOutput() ; Empty the $OUTPUT $BUFFER
EndFunc

I am running this from component from my Windows 7 x64 bit Powershell 3.0 version, and it still is working fine.

Enjoy !

ptrex

Edited by ptrex
1 person likes this

Share this post


Link to post
Share on other sites



Thank you for this - it is def. useful! :-)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Is ActiveXPoSH integreted in PrimalScript 2012? I cannot see a seperate download link for it!

Sound very interesting to have a bridge to PS! :)

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

@ UEZ

Yes, it is integrated in PS 2012.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@All

It is many years back that I downloaded this. But I think nowadays you first need to register an account, to get access to the download section.

If you click on download you get there http://www.sapien.com/auth

It is available as free standalone download.

rgds

ptrex

Edited by ptrex

Share this post


Link to post
Share on other sites

@ ptrex

Is it possible to load a PowerShell Console File like using the Parameter "-PSConsoleFile"?

Share this post


Link to post
Share on other sites

Powershell - COM

Many Windows Business Application are now only supporting Powershell, as a scripting environment.

Like MS Exchange / SharePoint / Active Directory / MS SQL / etc.

Do you have a Microsoft link describing when/why Active Directory is only supported by PS?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Water,

Oeps did I enter on your domain ;)

Let me refine what I meant.

Powershell uses uses .NET objects that are just not completely available using COM ADSI.

Therefore Powershell can and will simplify your life as administrator.

Writing a 1 liner to do the job, instead of 15 lines makes a difference.

Out of curiosity how to do you list all deleted AD object using your UDF ?

PS:

Your UDF is still very usefull don't misunderstand me !

rgds

ptrex

Share this post


Link to post
Share on other sites

Hi ptrex

sorry if my post was misleading! You didn't enter on my domain.

I just like to know what goes on so I can support users of my UDF as good as possible.

I have never tried to list deleted items. Are they moved to another OU before actually being deleted?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Thanks for posting this ptrex.

I actually looked for this for a long time after powershell was released. I expected it would be created by Microsoft, but when it wasn't, I figured it would show up from ActiveState if at all. When it didn't appear there, I gave up hope for it.

Too bad I didn't know about it earlier, but it will be very handy.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Haven't tried the PS COM utility yet. I'm on vacation right now.

If a new problem arises that can't be solved with the current UDF I will do some testing with the PS COM utility.

The rewrite of the Word and Excel UDF will need my full attention during the next weeks.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

This makes Au3 a handicapped scripting environment for administrators to work with

And also for crafty indirect GUIs:

$ActiveXPosh = ObjCreate("SAPIEN.ActiveXPoSH")
$success = $ActiveXPosh.Init(False) ;Do not load profiles
; Try GUI
$Line = ''
$Line &= '[reflection.assembly]::LoadWithPartialName( "System.Windows.Forms")' & @CrLf
$Line &= '$form= New-Object Windows.Forms.Form' & @CrLf
$Line &= '$button = New-Object Windows.Forms.Button' & @CrLf
$Line &= '$button.text = "AutoIt is here!"' & @CrLf
$Line &= '$form.text = "PowerShell WinForms GUI from AutoIt"' & @CrLf
$Line &= '$form.Size = New-Object Drawing.Point 450,200' & @CrLf

; Create the label control and set text, size and location
$Line &= '$label = New-Object Windows.Forms.Label' & @CrLf
$Line &= '$label.Location = New-Object Drawing.Point 50,30' & @CrLf
$Line &= '$label.Size = New-Object Drawing.Point 300,15' & @CrLf
$Line &= '$label.text = "Enter your name and click the button:"' & @CrLf
; Create TextBox and set text, size and location
$Line &= '$textfield = New-Object Windows.Forms.TextBox' & @CrLf
$Line &= '$textfield.Location = New-Object Drawing.Point 50,60' & @CrLf
$Line &= '$textfield.Size = New-Object Drawing.Point 350,30' & @CrLf
; Create Button and set text and location
$Line &= '$button = New-Object Windows.Forms.Button' & @CrLf
$Line &= '$button.text = "Welcome to AutoIt"' & @CrLf
$Line &= '$button.Location = New-Object Drawing.Point 200,90' & @CrLf
; Set up event handler to extarct text from TextBox and display it on the Label.
$Line &= '$button.add_click({$label.Text = "Hi, " + $textfield.text})' & @CrLf
; Add the controls to the Form
$Line &= '$form.controls.add($button)' & @CrLf
$Line &= '$form.controls.add($label)' & @CrLf
$Line &= '$form.controls.add($textfield)' & @CrLf
; Display the dialog
$Line &= '$form.ShowDialog()' & @CrLf
$ActiveXPosh.Execute($Line)

Thank for your message about the Sapien Technologies News.


The point of world view

Share this post


Link to post
Share on other sites

Yes I know, this opens up a gate to all the .Net objects.

Good news is also that PowerShell Analyze (http://www.powershellanalyzer.com/)

IS NOW 100% FREE like ActiveXPoSH.

Posted Image

Early (2007) I've automated it through it's control class name, ie WindowsForms10.window.8.app.0.378734a1 and so on.

Sincerely,

Val...


The point of world view

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

This is exactly what I need and have been looking for for ages! but it doesn't work :-(

Is there a way to get this to create a 64bit com object? what happens is I am able to run the example and it will run commands however the command I really need to run is "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin" so I can do exchange stuff. on my 64 bit system this cannot be done from a 32 bit instance of powershell. it just returns that the snap in is not installed.

is there a way to get this to work properly in 64bit ?

EDIT: just to check based on some other stuff I did try to add the .dll directly to windows/system32 and ran regasm 64bit to register the thing but no dice. still won't see the object if i have usex64=y

Edited by SpinningCone

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

@SpinningCone

I have not see a x64 version around I am afraid :-(

My only source is Google

rgds

ptrex

PS : You will need to put money on the table to buy the later version of Primal Scripts x32 and x64 compatible

http://www.sapien.com/blog/2011/06/13/back-from-teched-2011-does-it-support-sharepoint-and-exchange/

Edited by ptrex

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • hemichallenger
      By hemichallenger
      Not sure if this is possible or if someone has already tackled this. Is it possible to embed PowerShell into a GUI? Autoit is great for quick function but sometime I need to run a command thru PowerShell. It be great to have PowerShell console embedded into the gui.
    • BigDaddyO
      By BigDaddyO
      After much searching I finally found a method to get eMails from an Exchange eMail account inbox.  I was hoping for AutoIT or vbscript but I couldn't find any that would read the inbox messages without using Outlook.
      I needed this because I'm testing a web-form that generates an eMail sent to a shared mailbox "not what my current outlook is configured for".  so, I needed to connect to a different account, then get the inbox messages, and see if the auto-generated eMail message body contains what I submitted in the form.
       
      I found a PowerShell script that was close and modified it to do just what I want, but I'd still like it to run in AutoIT but I'm not sure how to use the Microsoft.Exchange.WebServices.dll
      Anybody have some ideas? 
      #To Launch! # C:\Windows\System32> powershell -ExecutionPolicy ByPass #This launches PowerShell and allows execution of .ps1 files # PS C:\Windows\System32> . "C:\Temp\eMail\getInbox.ps1" #The period . in front of the .ps1 file forces PS to display results on-screen # Where is the EWS .DLL file that you are using # Get the installer from https://www.microsoft.com/en-us/download/details.aspx?id=42022 # We only need 2 dll's from the install and they can be stored anywhere: "Microsoft.Exchange.WebServices.Auth.dll" & "Microsoft.Exchange.WebServices.dll" $EWSdll = "C:\Temp\eMail\Microsoft.Exchange.WebServices.dll" # Where do you want the output text file to be saved $Output = "C:\Temp\eMails.txt" # replace with your email address $email = "MyemailAddress@work.net" # only need to populate these if you're impersonating... $username = "myemail" $password = "Sup3rS3cre+" $domain = "ad.work.net" # load the assembly : point to the dll in the location you have the .dll file [void] [Reflection.Assembly]::LoadFile($EWSdll) # set ref to exchange, first references 2007, 2nd is 2010 (default) #$s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1) $s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService # use first option if you want to impersonate, otherwise, grab your own credentials with the 3rd one. not sure what the 2nd one is for $s.Credentials = New-Object Net.NetworkCredential($username, $password, $domain) ##$s.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials #$s.UseDefaultCredentials = $true # discover the url from your email address $s.AutodiscoverUrl($email) # get a handle to the inbox $inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($s,[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox) #create a property set (to let us access the body & other details not available from the FindItems call) $psPropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) $psPropertySet.RequestedBodyType = [Microsoft.Exchange.WebServices.Data.BodyType]::Text; # If you have a set number of items you want to get, use this and insert the # in the () # $items = $inbox.FindItems(5) # If you want to retrieve all items (Server limit is usually at 1000) then use this line # Details on the max returned by server: https://blogs.msdn.microsoft.com/exchangedev/2010/03/12/throttling-policies-and-the-ewsfindcountlimit/ $items = $inbox.FindItems($inbox.TotalCount) # Put some counts at the top of the output Write-host "Total Inbox count: $($inbox.TotalCount)" Write-host "Unread count: $($inbox.UnreadCount)" #These two lines, write the output to the specified text file Add-Content $Output "Total Inbox count: $($inbox.TotalCount)" Add-Content $Output "Unread count: $($inbox.UnreadCount)" foreach ($item in $items.Items) { # load the property set to allow us to get to the body $item.load($psPropertySet) # Get the Body text as-is $bod = $item.Body.Text #if you only want a short summary of the Body, then comment the above line and un-comment these 4 lines # $bod = $item.Body.Text -replace '\s+', ' ' # $bodCutOff = (100,$bod.Length | Measure-Object -Minimum).Minimum # $bod = $bod.Substring(0,$bodCutOff) # $bod = "$bod..." # output the results - first of all the From, Subject, References and Message ID write-host "====================================================================" Write-host "From: $($item.From.Name)" Write-host "Subject: $($item.Subject)" Write-host "Body: $($bod)" write-host "====================================================================" "" # Output the results to the specified Text file Add-Content $Output "" Add-Content $Output "====================================================================" Add-Content $Output "From: $($item.From.Name)" Add-Content $Output "Subject: $($item.Subject)" Add-Content $Output "Body:",$($bod) Add-Content $Output "====================================================================" Add-Content $Output "" } #see these URLs for more info # EWS Stuff # folder members: https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.folder_members%28v=exchg.80%29.aspx # exporting headers: https://www.allabout365.com/2010/10/export-email-headers-exchange-powershell/ # read emails with EWS: https://social.technet.microsoft.com/Forums/en-US/3fbf8348-2945-43aa-a0bc-f3b1d34da27c/read-emails-with-ews?forum=exchangesvrdevelopment  
      Thanks,
      Mike
    • Jibberish
      By Jibberish
      Hi all,
      I need to read a log file into an array, but the log file is encoded as $FO_UTF16_BE_NOBOM (2048) = Use Unicode UTF16 Big Endian (without BOM) per FileGetEncoding (it returns 2048).
      I have searched how to convert these log files to UTF-8 and finally found a Powershell command. Since then I have been racking my brain trying to get the function to work. The command itself works from a Powerscript prompt:
      C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content C:\Logs\Myplayer_10-10-17-02-31.log | Set-Content -Encoding utf8 C:\Logs\Myplayer1.log This is my sandbox;
      #include <array.au3> #include <File.au3> Local $aArrayLogFile Local $sLogDir = "C:\Logs\" Local $sLogFile = "Myplayer_10-10-17-02-31.log" Local $sConvertedLog = "ConvertedLog.log" Local $sLogDirFile = $sLogDir&$sLogFile RunWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) _FileReadToArray($sLogDirFile, $aArrayLogFile) _ArrayDisplay($aArrayLogFile) Also tried
      RunWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) and
      ShellExecuteWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"," -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) Tried without -Command and a bunch of other parameters that were sprinkled throughout the internet from people trying to get this to work.
      Thanks
      Jibs
    • ur
      By ur
      I am maintaining all the reusable code in a separate file as library.au3.
      In that file I have referenced some dependent files using fileinstall, so that they will be extracted when necessary.
       
      Problem is, if I use a function in the library.au3 in another script which doesn't require this dependent file, as I am including the whole file using include tag, it is embedding that file also.
      Is there any way to exclude that.
       
    • david1337
      By david1337
      Hi guys,
      I need a little help here
      I have this simple Powershell script, that is able to set "sig.htm" as signature in OWA for the mail account specified.
      First part of the script just loads the Exchange snapin, since this is needed for the Get-Mailbox command.
      #Add Exchange 2010/2013 snapin if not already loaded in the PowerShell session if (!(Get-PSSnapin | where {$_.Name -eq "Microsoft.Exchange.Management.PowerShell.E2010"})) { try { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction STOP } catch { #Snapin was not loaded Write-Warning $_.Exception.Message EXIT } . $env:ExchangeInstallPath\bin\RemoteExchange.ps1 Connect-ExchangeServer -auto -AllowClobber } $mailboxes = Get-Mailbox -Identity user@domain.com $mailboxes| foreach {$file= "sig.htm"; Set-MailboxMessageConfiguration -identity $_.alias -SignatureHtml "$(Get-Content -Path $file -ReadCount 0)"} What I want is for AutoIt to use Powershell.exe to run the script somehow. This way I would be able to use AutoIt variables and arrays together with the PS script.
       I guess the solution would be to run Powershell.exe with command line arguments?
      If that is not possible, maybe have the script stored as a "ps1" file, and interact with it that way? (not preferred)