Powershell session

Home Forums Scripting PowerShell Powershell session

This topic contains 3 replies, has 3 voices, and was last updated by  weirdo 1 year, 5 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts

  • jason0923
    Participant
    #167061

    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?


    JeremyW
    Moderator
    #271499

    If you have conflicting cmdlets you can use the following syntax to specify the module you want to use:
    verb-noun[/CODE]
    e.g.
    [CODE]Hyper-VGet-VMHost[/CODE][CODE]verb-noun[/CODE]
    e.g.
    Hyper-VGet-VMHost[/CODE][CODE]Hyper-VGet-VMHost[/CODE]


    JeremyW
    Moderator
    #271500

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

    Import-Module Hyper-V -Prefix Pre1[/CODE]
    Then your commands would all have the prefix in front of the noun for the module. E.g.
    [CODE]Get-Pre1VMHost[/CODE][CODE]Import-Module Hyper-V -Prefix Pre1[/CODE]
    Then your commands would all have the prefix in front of the noun for the module. E.g.
    Get-Pre1VMHost[/CODE][CODE]Get-Pre1VMHost[/CODE]


    weirdo
    Member
    #390575

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

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.