Execute powershell command (new-object -comObject ...) in management pack

Hello everyone
I have a COM Object that want to use it in my management pack. When I write the powershell command "new-object -comObject ... " to create it outside of MP and in a ps1 file it works without any error. However when I write it in my MP, this
error is showed in event viewer: "Retrieving the COM class factory for component with CLSID {clsID} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))."
I have to mention that when I use vb script in my MP and using "CreateObject()", I don't have any problem.
How can I use "new-object -comObject ... " in my management pack?
thank you all
Alireza

Hi Marthijn,
Actually I don't have any problem with powershell in my management packs. For example I can use "MOM.ScriptAPI"
to create $oBag and return it to next module. My problem is only with that custom COM object. Interesting thing is that, it
works fine when I create it in powershell file outside of MP, but when I create it in my MP, that error occures.
thank you so much
Alireza

Similar Messages

  • NOOB Q: Does the New-Object -ComObject cmdlet not respect -ErrorAction SilentlyContinue?

    I'm trying to test to see if a set of COM interfaces have been registered on the system or not.  In my script I'm running the New-Object command to attempt to instantiate a COM object using the ProgID of each of the COM interfaces but I don't want errors
    displayed to the screen when one of the ProgIDs isn't registered on the system.  The New-Object help says it supports the <CommonParameters> but when I attempt to use "-ErrorAction SilentlyContinue" I still get the errors displayed
    in the PoSh session.
    I'm running the cmdlet below and getting the error output below that.  Is this the correct way to test a set of COM interfaces or is there another option?  If this is the correct way, is there a way to run the command such that it doesn't display
    an error for the COM interfaces that aren't registered?
    Command:
    New-Object -ComObject "myProgID" -ErrorAction SilentlyContinue
    Error:
    New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 REGDB_E_CLASSNOTREG)).
    At line:1 char:11
    + $comObj = New-Object -ComObject "Fake_ProgID" -ErrorAction SilentlyContinue
    +           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
        + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

    yep, use try / catch:
    try { New-Object -ComObject "myProgID" -ErrorAction Stop } catch { "not found" }
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
    Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

  • Hep with New-Object -ComObject InternetExplorer.Application on Powershell ISE

    Hi All,
    I'm trying to  work on powershell ISE (windows 7) with New-Object -ComObject InternetExplorer.Application. My issue is that I can set a variable like this:
    $iemessage = $ie.Document.Body.InnerText
    Beacuse for some reason will be a null variable, this is the code that I'm using which do not work on ISE, but it works on the normal porwershell console
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.Navigate("http://www.microsoft.com/technet/scriptcenter/default.mspx")
    $iemessage = $ie.Document.Body.InnerText
    this is the error I get when I use $iemessage | get-member
    Get-Member : No object has been specified to the get-member cmdlet.
    Thanks in advance for any suggestion.

    Hi,
    I have no explanation for why this adjustment works (I don't do much IE automation):
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.Navigate("http://www.microsoft.com/technet/scriptcenter/default.mspx")
    Start-Sleep -Seconds 1
    $iemessage = $ie.Document.Body.InnerText
    The old adage of 'if you run out of options, just take a nap and see if the problem fixes itself' seems to have worked yet again.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Execute powershell commands on a VM from the host.

    I’m wondering if it’s possible to execute PowerShell commands from the host that will be execute on a virtual machine.
    I have around 10 VM and I need to run the same command on all of it and I need to do the same in other 15 host.  
    None of the VM belong to the same domain.

    Yes, it's possible. 
    It's not recommended to do any administrative tasks from the host. You should remove the GUI and all roles from the host except things related to Hyper-V and used in your environment like Failover Clustering and MPIO. 
    As a best practice, set a Windows 8.1 VM as your management station and install RSAT tools on it including Hyper-V Manager. It also comes with Powershell modules you need to run Powershell commands and scripts against all your hosts and VMs.
    On the machines to be managed by Powershell you need to enable Powershell Remoting. In Server 2012 and above and Windows 8 and above this is enabled out of the box (even core versions). In older versions of Windows
    enable Powershell Remoting manually as shown in this post.
    On the management Win 8.1 VM that has RSAT installed, if the managed machines belong to the same domain as the managing station, you're good to go. If not, run this command on the managing station:
    winrm s winrm/config/client "@{TrustedHosts=""My2003Server,host2,host3,vm4""}"
    Execute your scripts against multiple machines by using Invoke-Command as in:
    'Computer1','Computer2','Computer3' | % {
    $Result = Invoke-Command -Computer $_ -ScriptBlock {
    Get-Process
    $Result
    This example, will execute the commands in the scriptblock on each of the 3 computers in line1, and return the result.
    For more information see
    Don Jones' Secrets of Powershell Remoting eBook.
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
    Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

  • Execute PowerShell Scripts via SAP NetWeaver Identity Management

    Hello,
    Has anyone implemented the execution of a PowerShell script from SAP NetWeaver Identity Management (7.1, 7.2, 8.0?).  Currently implementing 8.0, and our client is looking to kick off PowerShell scripts that would generate Active Directory accounts, Exchange accounts etc.
    Thanks!

    Hey Brendan,
    We've done this out of a 7.2 implementation for exchange 2010 admin processes.  We started with running powershell via a command line pass.  It worked pretty well but it wasn't plain sailing.  We used positional parameters to pass data to the scripts in question, we also had to come up with a return process that deals with any errors that might come of the powershell session.  We had some issues with the shell sessions closing after the script completed.
    We've since redesigned and now drop flat files to a constantly running powershell script that acts a bit like an IDM dispatcher (but obviously not integrated with IDM).  It kicks off other powershell sessions and monitors their progress allowing it to process time outs, stack work up, etc.
    We also found timing the processes to be an issue.  If you create an AD account in IDM and then try to immediately move onto mailbox enable (for example) the account we created wasn't yet replicated to exchange so we had to build wait time into various parts of the process.
    Thanks,
    Pete.

  • Linux Server to connect Windows 2008 R2 Server to execute powershell commands

    Is it possible to do remotely executing powershell scripts on Windows 2008 R2 from Linux Server. I explored the option of FreeSSHD, but there is no option for password less authentication.
    Any thoughts and hints greatly appreciated.
    Retheesh
    Thanks and Regards, Retheesh Kumar R

    I am going to respectfully disagree with my post mates! Muhahahaha!
    If the target server (your Windows 2008 R2 box) can accept secure shell (ssh) connections, you should be able to ssh into the server then start PowerShell just like any other shell. That said, I suspect you will run into quirks. For example, I bet the
    "out-gridview" commandlet does some whacky stuff. You may get some strange terminal emulation junk too, but by and large you should be okay. I have Cygwin deployed to a Windows machine. That installation includes the OpenSSH package.
    [1] Cygwin http://www.cygwin.com/
    [2] How to run the OpenSSH SSHD server on Windows using Cygwin;
    http://www.noah.org/ssh/cygwin-sshd.html
    This would be like ssh'ing into some Linux machine then firing up ksh. If you're used to Linux, you no doubt know what I'm talking about.
    Now, here is the trick. You'll have to setup key based authentication on the Windows machine once you have your SSH server all setup. If you know how to do this on Linux, its the same process for Cygwin. The following article can help you -- remember the
    process is pretty much the same for Cygwin on Windows as it is for Linux distributions:
    [3] SSH with authentication key instead of password;
    http://www.debian-administration.org/articles/530
    You have your work cut out for you. Give it a try, and tell us how you fare.
    I hope this helps bro!
    Cheers,
    A-

  • SCCM 2012 sp1: howto remotely execute powershell commands?

    Hi,
    Please advise on howto run remote powershell scripts to an SCCM 2012 SP1-server.
    Locally importing the module (on sccm 2012) works fine, but not remotely. It tells I should run from x86 console, but I am!
    Please advise.
    J.
    Jan Hoedt

    Start the SCCM Console and start Powershell from there. (left-top "Connect via Windows Powershell")
    This will register the CM PSDrive for the user who started the console.
    The PSDrive will not be available to a PowerShell IDE or another editor. However in looking at this, it shows that it's loading "Microsoft.ConfigurationManagement.PowerShell.Types.ps1xml". So I tried the following:
    Update-TypeData
    -PrependPath
    ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5)
    +
    '\Microsoft.ConfigurationManagement.PowerShell.Types.ps1xml')
    That seems to load the correct datatype. However I still get an error doing the following command (example):
    New-PSDrive
    -Name
    "CAS"
    -PSProvider
    CMSite
    -Root
    "ServerUNC"
    Error:
    New-PSDrive : Object reference not set to an instance of an object.
    Hopefully someone knows more about TypeData...
    -Ken

  • The underlying connection was closed: An unexpected error occurred on a receive..Exception.Message - while executing powershell command for sharepoint online site

    " +The underlying connection was closed: An unexpected error occurred on a receive..Exception.Message " OR sometimes
    "The remote server returned an error: (503) Server Unavailable..Exception.Message"
    Getting exception above when performing various operation (site coll creating, group creation, adding users to group) for sharepoint online (Office 365) site using powershell script.
    I want to create 3500 site collections using PS script. In-between getting above exception so it will skip one site collection creating and working again. for eg. after creating 11 site coll, script will through above exception and so 12th site coll will
    not be create but working fine from 13 and so on...

    Remote server seems working to me...any additional check?
    if problem with remote server then may be loop to create site provisioning should not start again..Right?
    any idea?

  • Error while Seq vlc in powershell command line.

    Hi Team,
    when i am trying to seq Vlc i got below error in power shell.
    i have entered below command lines in powershell
    1. cd c:\install
    2. Set-ExecutionPolicy Unrestricted
    3. New-AppvSequencerPackage -FullLoad -Installer "C:\Install\vlc-2.1.3-win32.exe" -Name "Unknown_VLC_2.1.3_01_W7_32_A" -Pa
    th C:\Packages -PrimaryVirtualApplicationDirectory "C:\Windows" -TemplateFilePath .\AppV5SequencerTemplate.appvt -Verbo
    se
    after it's called "C:\Install\vlc-2.1.3-win32.exe", i did default install and clicked close button.
    after 5 mint's i got below error.
    could you please help me to solve.
    1. AppV5SequencerTemplate.appvt file present in c:\installer folder
    2. c:\packages folder created
    Thanks in Advance :)
    Ramesh
    PS C:\Install> New-AppvSequencerPackage -FullLoad -Installer "C:\Install\vlc-2.1.3-win32.exe" -Name "Unknown_VLC_2.1.3_01_W7_32_A" -Pa
    th C:\Packages -PrimaryVirtualApplicationDirectory "C:\Windows" -TemplateFilePath .\AppV5SequencerTemplate.appvt -Verbo
    se
    Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indi
    cation that other memory is corrupt.
    at PE.ComputeMinFileRanges(PE* )
    at ResolveDependencies(IPackageFile file, IEnumerable`1 files, Func`4 fnGetDependencyPathFromName, Func`2 fnGetLocalP
    athOfPackageFile, HashSet`1 dependencies, HashSet`1 visited)
    at Microsoft.ApplicationVirtualization.Packaging.PEScanner.BuildDependencies(IEnumerable`1 allPackageFiles, Func`2 pr
    edicate, Func`4 fnGetDependencyPathFromName, Func`2 fnGetLocalPathOfPackageFile)
    at Microsoft.ApplicationVirtualization.Packaging.StaticDependencyPackagingSubsystem.<>c__DisplayClass8.<.ctor>b__0(Ob
    ject sender, CommonPreEventArgs args)
    at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
    at Microsoft.ApplicationVirtualization.Packaging.PackagingEngine.OnFinalizePackage(Func`1 writerFactory)
    at Microsoft.ApplicationVirtualization.Packaging.PackagingEngine.<>c__DisplayClass18.<FinalizePackage>b__12()
    at Microsoft.ApplicationVirtualization.Packaging.WithAppCorruptionCheck.Execute(Action execute, Action`1 logCorruptio
    n)
    at Microsoft.ApplicationVirtualization.Packaging.WithAppCorruptionCheck.Execute(Action execute)
    at Microsoft.ApplicationVirtualization.Packaging.PackagingEngine.<>c__DisplayClass18.<FinalizePackage>b__11()
    at Microsoft.ApplicationVirtualization.Packaging.ExceptionGuard`1.Guard(Action logStart, Action execute, Action logEn
    d, Action`1 exceptionAction)
    at Microsoft.ApplicationVirtualization.Packaging.PackagingEngine.FinalizePackage(Func`1 writerFactory)
    at Microsoft.ApplicationVirtualization.Packaging.Packager.FinalizePackage(IPackageFiles packageFiles, String manifest
    Path, String registryHivePath, String streamMapPath, String packageHistoryPath, String installPath, String installShortP
    ath, String packagePath, CompressionOption compression, Predicate`1 addFileToPublishingFeatureBlock, PackagingEngineType
    engineType, PackagerParameters packageParameters)
    at Microsoft.ApplicationVirtualization.Packaging.Sequencing.PackagerAdapter.FinalizePackage(IPackageFiles packageFile
    s, String manifestPath, String registryHivePath, String streamMapPath, String packageHistoryPath, String installPath, St
    ring packagePath, CompressionOption compression, PackagerParameters packagerParameters)
    at Microsoft.ApplicationVirtualization.Packaging.Sequencing.PackagerOrchestrator.FinalizePackage(String streamMapPath
    , String packagePath, String manifestPath, String registryHivePath, String packageHistoryPath, String installPath, Compr
    essionOption compression, Boolean toAppendVersionNumberToFileName, PackagerParameters packagerParameters)
    at Microsoft.AppV.Modernizer.Cmdlets.NewAppvSequencerPackage.CreatePackageViaInstaller(String packageName, String out
    putDirectoryPath, String primaryApplicationVirtualDirectory, String installer, String templatePath, Boolean fullLoad, Fu
    nc`1 fnSequencerFactory, Func`2 fnMonitoringSessionManagerFactory, Func`1 fnSequencerStateFactory, Func`2 fnTaskScannerA
    dapterFactory, Func`2 fnPackagerOrchestratorFactory, Func`1 fnSequencerTemplateFactory, Func`2 fnExclusionListFactory, A
    ction`1 fnWait, Action fnConfigurePrivileges, Func`2 fnOutputDirectoryExists, Func`2 fnOutputSubdirExists, Action`1 fnCr
    eateDirectory)
    at Microsoft.AppV.Modernizer.Cmdlets.NewAppvSequencerPackage.CreatePackageViaInstaller(String packageName, String out
    putDirectoryPath, String primaryApplicationVirtualDirectory, String installer, String templatePath, Boolean fullLoad)
    at Microsoft.AppV.Modernizer.Cmdlets.NewAppvSequencerPackage.NewPackage()
    at Microsoft.AppV.Modernizer.Cmdlets.NewAppvSequencerPackage.<ProcessRecord>b__1()
    at Microsoft.AppV.Modernizer.Cmdlets.ExceptionGuard.Guard(Action logStart, Action execute, Action logEnd, Action`1 er
    rorAction)
    at Microsoft.AppV.Modernizer.Cmdlets.NewAppvSequencerPackage.ProcessRecord()
    at System.Management.Automation.CommandProcessor.ProcessRecord()
    at System.Management.Automation.CommandProcessorBase.DoExecute()
    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorR
    esults, Boolean enumerate)
    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInterna
    l[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcCo
    ntext)
    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
    at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean crea
    teLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Obj
    ect dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
    at System.Management.Automation.ScriptBlock.<>c__DisplayClassa.<InvokeWithPipe>b__8()
    at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
    at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, Dictionary`2 functionsToDefine, Lis
    t`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis,
    Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
    at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandl
    ingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args)
    at Microsoft.PowerShell.Commands.InvokeExpressionCommand.ProcessRecord()
    at System.Management.Automation.CommandProcessor.ProcessRecord()
    at System.Management.Automation.CommandProcessorBase.DoExecute()
    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorR
    esults, Boolean enumerate)
    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInterna
    l[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcCo
    ntext)
    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
    at System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object in
    putToProcess)
    at System.Management.Automation.CommandProcessorBase.DoComplete()
    at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(CommandProcessorBase commandRequestingUpstr
    eamCommandsToStop)
    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorR
    esults, Boolean enumerate)
    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInterna
    l[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcCo
    ntext)
    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
    at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
    at System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object in
    putToProcess)
    at System.Management.Automation.CommandProcessorBase.DoComplete()
    at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(CommandProcessorBase commandRequestingUpstr
    eamCommandsToStop)
    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorR
    esults, Boolean enumerate)
    at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
    at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()
    at System.Management.Automation.Runspaces.PipelineThread.WorkerProc()
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object
    state, Boolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, B
    oolean preserveSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    PS C:\Install>

    Thanks for your replay
    i have re- seq'd it's working..
    Thanks
    Er Reddy

  • How to Stop the powershell command execution in C#

    I am executing powershell command synchronously. Binded a eventhandler, which
    runs successfully when data is emitted by pipeline. When some condition met, i wish to stop powershell command execution,
    but when i call pipeLine.Stop(), program just hangs indefinitely. May i know what is going wrong?
    Command shellCommand = new Command("Get-MsolUser");
    Pipeline pipeLine = powerShellRunspace.CreatePipeline();
    pipeLine.Commands.Add(shellCommand);
    pipeLine.Input.Close();
    pipeLine.Output.DataReady += delegate(object sender,EventArgs args) {
    try {
    PipelineReader<PSObject> output = sender as PipelineReader<PSObject>;
    if (output != null) {
    bool isCompleted = false;
    while (output.Count > 0 && !isCompleted) {
    PSObject pso = (PSObject)output.Read();
    isCompleted = addDataDelegate(pso);
    if (isCompleted) {
    pipeLine.Stop(); //HANGS HERE
    log("JUST STOPPED PIPELINE..");
    } catch(Exception ex) {
    log(ex.ToString());
    pipeLine.Invoke();

    You may need to switch to InvokeAsync. I can't find any documentation on this, so it may come down to trial and error, but the synchronous Invoke method may not be playing well with attempts to call pipeLine.Stop().

  • Data Mining shared mail box using powershell via com object Performance is really bad.

    I was trying to pull a report from multiple shared mail boxes by configuring them in outlook. Everything works fine for me here but the problem is that the below script would need a minimum of 10-14 hours on weekly basis. Can you please comment me on how
    can I get more performance? My average mailbox details and my observations are as below:
    It would have about 35 sub folders recursively up to 3 levels in Inbox.
    It would have ~ 300,000 to 400,000 emails.
    I donot know if this can be easily accomplished via EMC Shell but I dont have it either.
    And these are configured in Outlook 2013.
    The biggest folder has about 60000 emails.
    Even plain export without any filter or calculated values in the output is taking the similar time.
    I have even tried to use pick folder and manually executed multiple instances (~10) for each folder but the performance was really worst.
    -------------------------Script Starts here--------------------------------------
    Filter WeeklyReport {If((($_.SentOn -ge ("12/14/2014" -as [datetime])) -and ($_.SentOn -le ("12/20/2014" -as [datetime])))){$_}}
    $ReportFileName="~\Desktop\EMail_Export_$(get-date -f yyyy-MM-dd-HH-mm).csv"
    function GetSubfolders($Parent) { 
        $folders = $Parent.Folders 
        foreach ($folder in $folders) { 
            $Subfolder = $Parent.Folders.Item($folder.Name) 
            Write-Host ("Started processing"+$folder.Name +" at "+$(Get-Date)+" which has "+$folder.items.Count + " items ") -NoNewLine
            $folder.Items | WeeklyReport | Select-Object -Property SenderEmailType,ConversationTopic,CreationTime,ReceivedTime,Importance,LastModificationTime,Size,Subject,CC,ReceivedByName,ReceivedOnBehalfOfName,SenderName,SentOn,SentOnBehalfOfName,To,SenderEmailAddress,Categories,@{N='FolderName';E={$($folder.Name)}}
    | epcsv -Path $ReportFileName -NoTypeInformation -Append
            Write-Host ($(Get-Date))
            GetSubfolders($Subfolder) 
    Add-Type -AssemblyName "Microsoft.Office.Interop.Outlook"
    $olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
    $outlook = New-Object -ComObject outlook.application
    $namespace = $outlook.GetNamespace("MAPI")
    $MailBox=$namespace.Folders | ?{$_.Name -eq "[email protected]"}
    $MailBoxInbox=$MailBox.Folders | ?{$_.Name -eq "Inbox"}
    Write-Host ("Started processing Inbox at "+$(Get-Date)+" which has "+$MailBoxInbox.items.Count + " items") -NoNewLine
    $MailBoxInbox.Items | WeeklyReport | Select-Object -Property SenderEmailType,ConversationTopic,CreationTime,ReceivedTime,Importance,LastModificationTime,Size,Subject,CC,ReceivedByName,ReceivedOnBehalfOfName,SenderName,SentOn,SentOnBehalfOfName,To,SenderEmailAddress,Categories,@{N='FolderName';E={'Inbox'}}
    | epcsv -Path $ReportFileName -NoTypeInformation -Force
    Write-Host ($(Get-Date))
    GetSubfolders($MailBoxInbox)
    $outlook.quit()
    -------------------------Script Ends here--------------------------------------
    --VenuGopal

    Aah, Sorry COM object....
    I have observed that for the execution of the below line hardly it is taking 1-2 seconds for processing 50,000 items and it is similar even if we dont apply the filter.
    $items=$Folder.Items.Restrict($sFilter)
    Just got a doubt and found that the performance issue is not while processing the data but export is taking so much of time. For Example: Execution of the below line starts giving out put on the fly.
    $items|Select-Property$props|ft-a
    Even Out-File is taking so much of time. So, I think I need to start looking out for string builder or Stream Writer rather using epcsv?
    --VenuGopal

  • Get an error when trying to add a new object!

    Post Author: zhaodifan
    CA Forum: Administration
    I was trying to add a new object from central management console and I got the following error:
    Retrieve Error
    There was an error while retrieving data from the server: Failed to read data from report file C:\WINNT\Temp\pres_report.rpt. Reason: Operation not yet implemented. File C:\WINNT\TEMP\tmpreport\~ci226c521bf2923e0.rpt.
    The report I am trying to add was running on a Linux box with the same version BusinessObjects Cyrstal 11 running. I want to move it to a Windows box... The report itself shouldn't have problems because it was running fine on the linux box...
    Also want you let you know that I don't know too much about Crystal Report and our Crystal Report admin quited his job last week! I will be very appreciated if anybody can give me any advice. Thank you!
    Difan

    If this is a Gmail account you might need to unlock by going here: https://accounts.google.com/DisplayUnlockCaptcha.

  • How can i use azure cmdlets in scom management pack scripts

    i want to show some of azure web site metrics in the scom console so i have script which gets the data from azure portal 
    how can i use that script in the scom management pack 
    [void][system.reflection.Assembly]::LoadFrom(“C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Automation\Microsoft.WindowsAzure.Common.dll”)
    $value=Get-AzureWebsiteMetric -Name "openemrmysql" -MetricNames "Http2xx" -TimeGrain "PT1M"
    $API = New-Object -ComObject "MOM.ScriptAPI"
    $PropertyBag = $API.CreatePropertyBag()
    $result=$value.Data.Values
    foreach($result in $value)
    $global:totalvalue=$result.value.Total -as [int]
    $PropertyBag.AddValue("AzureActive","AzureActive")
    $PropertyBag.AddValue("Active", $global:value)
    $PropertyBag
    i have included this script in the management pack and it is not creating any counter in the scom console.
    Can any one help me,
    thanks & Regards,
    Suresh Gaddam

    Hi,
    I would like to suggest you check articles below to get more information about PowerShell Scripts in a Management Pack:
    http://blogs.technet.com/b/brianwren/archive/2008/02/20/running-powershell-scripts-from-a-management-pack.aspx
    http://blogs.technet.com/b/brianwren/archive/2009/06/04/powershell-scripts-in-a-management-pack-part-2.aspx
    Regards,
    Yan Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Looking for a SQL query to get all the possible Alert Messages from the Rules in a Management Pack

    For reporting, I'm looking to get a SQL query of all the possible Alert Messages for Rules configured in a Management Pack (not necessarily the ones that have thrown alerts).  I can do this for Monitors, but not for Rules. 
    The configured alert messages for the Management Pack Monitors
    go like this:  ManagementPack > MonitorView> RuleModule > RuleModule.Alert Message > Localized Text
    The configured alert messages for the Management Pack Rules
    should go something like this, but there is a missing link:  ManagementPack > RuleView > RuleModule > ? Missing Link ? > Localized Text
    The Rules are tied to the Module, but I don't see a connection from the RulesModule to the Alert Message that I see in the LocalizedText. The Rule names do not always equal the Alert name. 
    Can someone provide the missing link?

    Hi,
    please try below powershell code to find the corresponding management pack for specific alert:
    $Alert = get-scomalert | where {$_.Name -like 'Agent Proxy Not Enabled*'} | select -first 1
    If ($alert.IsMonitorAlert -eq "True") {
    write-host "Ths is a monitor-generated alert"
    get-scommonitor -ID $Alert.MonitoringRuleID | select Enabled, DisplayName, ManagementPack
    else
    write-host "This is a rule-generated alert"
    get-scomrule -ID $Alert.MonitoringRuleID | select Enabled, DisplayName, ManagementPack
    In addition, please also refer to the below link:
    http://blogs.technet.com/b/mazenahmed/archive/2011/12/02/using-powershell-to-map-opsmgr-active-alert-to-its-corresponding-rule-monitor-and-management-pack-name.aspx
    Regards,
    Yan Li
    Regards, Yan Li

  • SOA management pack

    Hi All ,
    I am new to Oracle SOA management pack ,
    We have a requirement to install SOA management pack ,
    for that we have a CD which contains the below folders , can any one suggest us how to proceed ?
    EM 10-2-0-5-V16512-01_1of2
    EM 10-2-0-5-V16512-01_2of2
    Thanks
    Karthik

    http://download.oracle.com/docs/cd/B16240_01/doc/doc.102/e14396/toc.htm

Maybe you are looking for