News, tips, advice, support for Windows, Office, PCs & more. Tech help. No bull. We're community supported by donations from our Plus Members, and proud of it
Home icon Home icon Home icon Email icon RSS icon
  • Batching PowerShell commands

    Posted on CWBillow Comment on the AskWoody Lounge

    Home Forums AskWoody support Windows Windows 10 Batching PowerShell commands

    This topic contains 4 replies, has 4 voices, and was last updated by  joep517 1 week ago.

    • Author
    • #1977805 Reply

      AskWoody Plus

      I have a series of PowerShell commands:

      Set-ExecutionPolicy RemoteSigned
      $credential = Get-Credential
      Install-Module MSOnline
      $exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “” -Credential $credential -Authentication “Basic” -AllowRedirection
      Import-PSSession $exchangeSession -DisableNameChecking
      Set-MailboxJunkEmailConfiguration -Identity -Enabled     $false

      The last line is overflow fro the one above…

      Is there a way to put all these into a single batch file?



      Chuck Billow

      • This topic was modified 1 week ago by  joep517. Reason: obscure email address
    • #1977821 Reply

      AskWoody Lounger

      Is there a way to put all these into a single batch file?

      Yes. Any text editor, including Notepad, will do. Save with a .ps1 extension.

      PowerShell really is a complete programming language as well as interactive command interpreter.

      1 user thanked author for this post.
    • #1977933 Reply

      AskWoody Plus

      And bill you might want to reconsider displaying your email address


      Just because you don't know where you are going doesn't mean any road will get you there.
    • #1979800 Reply

      AskWoody Plus



      Chuck Billow

      • #1979816 Reply

        AskWoody MVP


        I obscured your email address. Putting your real address in a public forum is just asking to get more spam. Be careful about that in the future.


    Please follow the -Lounge Rules- no personal attacks, no swearing, and politics/religion are relegated to the Rants forum.

    Reply To: Batching PowerShell commands

    You can use BBCodes to format your content.
    Your account can't use Advanced BBCodes, they will be stripped before saving.