Power shell command to check a domain is whitelisted or not.

Balaji Raju Mohan 0 Reputation points
2023-03-06T05:14:24.9433333+00:00

Hi,

I am trying check if some of the domains are whitelisted or not in windows computer.

What is the command that I could use to check if those domains are whitelisted or not on Prod servers.

I have tried the Invoke-WebRequest but it saw could not connect to server.

Invoke-WebRequest https://collector.newrelic.com

Is there any other way I could check the whitelisted domains?

Thanks

Windows for business Windows Server User experience PowerShell
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2023-03-07T04:28:36.1833333+00:00

    Hi,

    If you are using the Windows Firewall, open Windows Defender Firewall with Advanced Security from the start menu and check if there are some rules block the IP addresses. To retrieve the firewall rules in PowerShell you can use Get-NetFirewallRule.

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Limitless Technology 44,746 Reputation points
    2023-03-07T08:26:13.73+00:00

    Hello there,

    Use the Get-AcceptedDomain cmdlet to view the configuration information for the accepted domains in your organization.

    https://learn.microsoft.com/en-us/powershell/module/exchange/get-accepteddomain?view=exchange-ps

    Here is the simple PowerShell script to get all whitelisted domains in Azure AD.

    $scriptpath = $MyInvocation.MyCommand.Path

    #Get the current directory of the file stored.

    $dir = Split-Path $scriptpath

    #Get current date

    $date = (get-date -f dd-MM-yyyy-hhmmss)

    #Set filename to store the output

    $Outfile = "$dir\Whitelisteddomains-"+$date+".csv"

    #connect to Azure AD (assuming,the AzureADPreview, for now, is being installed.)

    Connect-AzureAD

    #List all B2B domains based on the condition

    $data = (Get-AzureADPolicy | ? {$_.DisplayName -eq "B2BManagementPolicy" } | select definition)

    #replace single quote with escape charcter and double quotes

    $defs = $data.Definition.Replace('"',"""""")

    $allowedDomains = $defs.Substring($defs.indexof("[")+1)

    $allowedDomains = $allowedDomains.Substring(0,$allowedDomains.IndexOf("]"))

    #revert back the quotes back to normal node to see the real output

    $allowedDomains.Replace("""""","") | out-file $Outfile –Force

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.