/images/nasan-avatar.jpeg

ExchangeOnline Mailadressen anzeigen, hinzufügen, entfernen

ExchangeOnline Mailadressen anzeigen, hinzufügen, entfernen'

Exchange Online: Mailadressen anzeigen, hinzufügen, entfernen

Voraussetzungen

Das ExchangeOnlineManagment Module muss installiert, importiert sein und man muss sich mit der entsprechenden Exchange Online Umgebung verbinden:

ExchangeOnlineManagement Module in Powershell installieren: Install-Module -Name ExchangeOnlineManagement

Das Module importieren: Import-Module ExchangeOnlineManagement

Mit der Exchange Online Environment verbinden (run this command as admin, then login) Connect-ExchangeOnline -UserPrincipalName admin@customerdomain.onmicrosoft.com

Für die Befehle im lokalen AD, muss das ActiveDirectory Powershell Modul geladen sein: https://theitbros.com/install-and-import-powershell-active-directory-module/

How to show last bootuptime of Computers with Powershell

Use Get-CimInstance with the ClassName win32_operatingsystem

You can query the ClassName win32_operatingsystem and select from there the computername csname and the last bootup time lastbootuptime

Get-CimInstance -ComputerName 'DC01' -ClassName win32_operatingsystem | select csname, lastbootuptime

Show last bootuptime for multiple computers

If you want to do that for multiple computers you can for example do it wit a foreach loop:

# First query the computer from which you want to have this information:
$computer = Get-ADComputer -Filter * | where Name -Match dc
# Now get the lastbootuptime for every computer in the computer array:
foreach($c in $computer){
    $computername = $c.DNSHostname
    Get-CimInstance -ComputerName $computername -ClassName win32_operatingsystem | select csname, lastbootuptime
}

Which other information can you get from this class?

If you’re curious what other information you can get from this class you can simply run a Get-Member which will list you all properties and methods:

Search a specific entry over all GPO

A way to search a specific setting over all GPOs

Generate a GPO Report over your Domain

You can generate a GPO Report over your Domain either in a XML or HTML file and then search through that file.

To generate a XML use this command:

Get-GPOReport -All -Domain "domain.com" -Server "DC01" -ReportType XML -Path "C:\GPOReports\GPOReportsAll.xml"

To generate a HTML file you can use this command:

Get-GPOReport -All -Domain "domain.com" -Server "DC01" -ReportType HTML -Path "C:\GPOReports\GPOReportsAll.html"

All GPO settings will be included in this Report file. So you can search through that file and find your settings.

Run a gpresult on a remote computer

How to run a gpresult on a remote computer

Use the Invoke-Command

You can simply use the Invoke Command to run the gpresult command on a remote computer:

  • Define the ComputerName after the Invoke-Command
  • In the ScriptBlock you can simply run your command

here comes the new highlight:

199
200
Invoke-Command -ComputerName 'ComputerName' -ScriptBlock{
    gpresult /r /USER 'username'

Run gpresult for a specific User in a RDS environment

In the following script you just have to define the username + the RDS ConnectionBroker. It will automatically find the Remote Desktop Server where the user is logged in an run the gpresult there:

Initializing with Entra authority: https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0 https://login.microsoftonline.com:443 “GET /44db8ac1-2253-4cb0-8bb5-0252a10a64f0/v2.0/.well-known/openid-configuration HTTP/1.1” 200 1805

okay it basically get the OpenID config from here: https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0/v2.0/.well-known/openid-configuration this config: OpenID Configuration (formatted):

{
    "token_endpoint": "https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0/oauth2/v2.0/token",
    "token_endpoint_auth_methods_supported": [
        "client_secret_post",
        "private_key_jwt",
        "client_secret_basic"
    ],
    "jwks_uri": "https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0/discovery/v2.0/keys",
    "response_modes_supported": [
        "query",
        "fragment",
        "form_post"
    ],
    "subject_types_supported": [
        "pairwise"
    ],
    "id_token_signing_alg_values_supported": [
        "RS256"
    ],
    "code_challenge_methods_supported": [
        "plain",
        "S256"
    ],
    "response_types_supported": [
        "code",
        "id_token",
        "code id_token",
        "id_token token"
    ],
    "scopes_supported": [
        "openid",
        "profile",
        "email",
        "offline_access"
    ],
    "issuer": "https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0/v2.0",
    "request_uri_parameter_supported": false,
    "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo",
    "authorization_endpoint": "https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0/oauth2/v2.0/authorize",
    "device_authorization_endpoint": "https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0/oauth2/v2.0/devicecode",
    "http_logout_supported": true,
    "frontchannel_logout_supported": true,
    "end_session_endpoint": "https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0/oauth2/v2.0/logout",
    "claims_supported": [
        "sub",
        "iss",
        "cloud_instance_name",
        "cloud_instance_host_name",
        "cloud_graph_host_name",
        "msgraph_host",
        "aud",
        "exp",
        "iat",
        "auth_time",
        "acr",
        "nonce",
        "preferred_username",
        "name",
        "tid",
        "ver",
        "at_hash",
        "c_hash",
        "email"
    ],
    "kerberos_endpoint": "https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0/kerberos",
    "tenant_region_scope": "EU",
    "cloud_instance_name": "microsoftonline.com",
    "cloud_graph_host_name": "graph.windows.net",
    "msgraph_host": "graph.microsoft.com",
    "rbac_url": "https://pas.windows.net"
}

anschliessend der authorize link https://login.microsoftonline.com/44db8ac1-2253-4cb0-8bb5-0252a10a64f0/oauth2/v2.0/authorize?client_id=86cf2f4d-d1f3-4af4-9be2-fb4c089cffd5&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A5001%2Fcallback&scope=User.Read+offline_access+openid+profile&state=8f9a6415-6c46-48e1-bdb1-800232615e1c&code_challenge=BRlCLPwUybzs-0zo0fVJsXDpe_DuncvadxcocS7mKA0&code_challenge_method=S256&nonce=3d179adcb2c3756ffec18375f8a4df7bb0608d14432a5c8760d0684450bf3631&client_info=1&sso_reload=true