Announcement

Collapse
No announcement yet.

Powershell session

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Powershell session

    I'm trying to script some account stuff into one PS script. We use Local AD. Office 365 and hosted Exchange. Individually things work but for example I want to disable an account. The disable cmds have to run on local AD, the remove licenes and mailbox functions have to run on both the local and Office 365 Exchange servers. In the script I can connect to office 365 but some of the commands error out because they need to connect to local Exch and vice versa. Can I designate which connection to use for each command?

  • #2
    If you have conflicting cmdlets you can use the following syntax to specify the module you want to use:
    Code:
    <module>\verb-noun
    e.g.
    Code:
    Hyper-V\Get-VMHost
    Regards,
    Jeremy

    Network Consultant/Engineer
    Baltimore - Washington area and beyond
    www.gma-cpa.com

    Comment


    • #3
      Another option that you can use is to add a prefix when importing the modules:

      Code:
      Import-Module Hyper-V -Prefix Pre1
      Then your commands would all have the prefix in front of the noun for the module. E.g.
      Code:
      Get-Pre1VMHost
      Regards,
      Jeremy

      Network Consultant/Engineer
      Baltimore - Washington area and beyond
      www.gma-cpa.com

      Comment


      • #4
        I think I got it to work by just reconnecting to each session before each command. its a little sloppy but it works. Thanks

        Comment

        Working...
        X