Artikelbild PowerShell Security

Microsoft PowerShell

PowerShell was originally developed by Microsoft and has become an extremely powerful scripting and shell language for system administration since it was first released. Thanks to its platform independence, PowerShell is no longer limited to Windows, but also runs on macOS and Linux. This wide availability increases both versatility and popularity among administrators and developers.

Especially in Microsoft 365 administration, PowerShell can be used excellently to automate recurring tasks and efficiently manage complex scenarios. Here are some basic PowerShell commands that can be especially helpful when working with Microsoft 365.

29

MS365 | Azure – PowerShell

On-Premise PowerShell


PS | Active Directory

PS | DNS

PS | DHCP



PS | Exchange On-Premise

PS | Windows System

PS | Remote Management



27

An overview

Get-Help

  • How it works:
    • The command Get-Help is your guide to the world of PowerShell. It provides detailed information about PowerShell commands, including their syntax, parameters, and examples.
  • Application:
    • To get help with a specific command, simply Get-Help type followed by the command name, e.g. Get-Help Get-Process.
  • Extended use:
    • You can also Get-Help use parameters such as -Examples, -Detailed-Full , or -Online to get more specific information.

Set-ExecutionPolicy

  • How it works:
    • Use Set-ExecutionPolicy to specify which PowerShell scripts are allowed to run on your system. This is an important command to ensure the security of your system.
  • Application:
    • To change the execution policy, use Set-ExecutionPolicy, followed by the desired policy, for example Set-ExecutionPolicy RemoteSigned.
  • Policy options:
    • Common guidelines include Restricted, AllSigned, RemoteSigned and Unrestricted. Each has its own security levels and use cases.

Get-Command

  • How it works:
    • Get-Command lists all available commands in PowerShell. This is especially useful for discovering new commands or finding existing commands.
  • Application:
    • Just Get-Command type to get a list of all commands. You can also specify specific patterns or modules Get-Command -Module MicrosoftTeams, such as .
  • Advanced search:
    • You can also use Get-Command to search for commands that contain specific words, such Get-Command *Item*as , to see all commands that have “Item” in their name.

[COMMAND] -WhatIf

  • How it works:
    • When you -WhatIf attach to a command, PowerShell shows what would happen if the command was executed without actually executing it.
    • For example, suppose you want to delete a directory, but you’re not sure if the command works as expected. You can Remove-Item -Path C:\MeinVerzeichnis -WhatIf use to see what would happen if the directory was deleted.
  • Application:
    • Before running potentially dangerous commands such as Remove-Item, Stop-Service or changes to system settings.
  • Important:
    • Not all PowerShell commands support the -WhatIfparameter. It is important to Get-Help use to check if the parameter is available for a particular command.
28