If you thought I would leave you hanging with that basic introduction, I have to disappoint you 🤣 Now that you know the basics of working with the PSWriteHTML diagram, we just need to use additional parameters of cmdlets we already know. New-DiagramNode has multiple parameters that allow you to decide on how the node looks like. You can use built-in Icons or FontAwesome Icons or, like in my case, use external images. Since I wanted to have an Office 365 diagram, I've decided to use external images hosted on Icon Scout. But that is completely up to you. You can use your own images, images from any website, as long as you accept the risks of someone replacing your chosen Icon with something entirely different. I've searched on Icon Scout for Office 365 and was not disappointed. It provides beautiful icons that are quick and easy to use.
New-HTML -Online -FilePath $PSScriptRoot\MyDiagram.html {
New-HTMLDiagram {
# Those control layout / physics
New-DiagramOptionsLayout -HierarchicalEnabled $true #-HierarchicalDirection FromLeftToRight
New-DiagramOptionsPhysics -Enabled $true -HierarchicalRepulsionAvoidOverlap 1 -HierarchicalRepulsionNodeDistance 200
# Lets add nodes to the diagram representing Company A
New-DiagramNode -Label "Active Directory`nCompanyADawid.Local" -Id 'CompanyAAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyADawid.Local" -Id 'AzureADConnectCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label "Exchange`nCompanyADawid.local" -Id 'ExchangeCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-2-569302.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet1' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyALTD.onmicrosoft.com' -Id 'CompanyAO365' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Level 1
New-DiagramNode -Label 'OneDrive' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'Teams' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'SharePoint' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
}
} -ShowHTML
As you can notice in code, each of my diagram nodes, have
The level is responsible for the nodes' positioning and probably the most important parameter for this diagram.
As you can see above, we have added 8 nodes to the diagram, and with the level, we made sure its position on the diagram is fixed (only from top to bottom). If we wouldn't specify it – by default, it would be level 0 and look like this:
The next step is to add nodes for the second company. We repeat the process as above. Don't worry if you don't get Level right at the beginning. I experimented a bit on how to visualize the architecture best before I got my levels correctly decided. And, of course, you can extend the diagram with whatever content you choose. You can add more nodes with Domain Controllers, Sites, Users, and so on. I didn't need it on the migration diagram, but nothing stops you from doing so.
New-HTML -Online -FilePath $PSScriptRoot\MyDiagram.html {
New-HTMLDiagram {
# Those control layout / physics
New-DiagramOptionsLayout -HierarchicalEnabled $true #-HierarchicalDirection FromLeftToRight
New-DiagramOptionsPhysics -Enabled $true -HierarchicalRepulsionAvoidOverlap 1 -HierarchicalRepulsionNodeDistance 200
# Lets add nodes to the diagram representing Company A
New-DiagramNode -Label "Active Directory`nCompanyADawid.Local" -Id 'CompanyAAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyADawid.Local" -Id 'AzureADConnectCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label "Exchange`nCompanyADawid.local" -Id 'ExchangeCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-2-569302.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet1' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyALTD.onmicrosoft.com' -Id 'CompanyAO365' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Level 1
New-DiagramNode -Label 'OneDrive' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'Teams' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'SharePoint' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
# Lets add nodes to the diagram representing Company B
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet2' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyBSA.onmicrosoft.com' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Id 'CompanyBO365' -Level 1
New-DiagramNode -Label "Active Directory`nCompanyB.corp" -Id 'CompanyBAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyB.corp" -Id 'AzureADConnectCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Exchange Online' -Id 'ExchangeCompanyB' -ImageType squareImage -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-4-896276.png' -Level 0
New-DiagramNode -Label "OneDrive`nCompanyB" -Id 'OneDriveCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "Teams`nCompanyB" -Id 'TeamsCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "SharePoint`nCompanyB" -Id 'SharePointCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
}
} -ShowHTML
Since we have no links between nodes, the positioning horizontally is automatic and done by the module itself. We only defined levels, so there's nothing pushing nodes in the right direction. Levels make sure that nodes of the same type are on the same level, so it's easier to place them on the diagram visually. As you remember, we have defined with New-DiagramOptionsPhysics that node distance should be 200, and there should be no overlap, which you will soon see how it works when we define links. However, be informed that there are multiple ways to configure physics using different parameters. Feel free to experiment with those and see how it behaves in different situations. Whatever I'm showing you here is just one way to do it. The next step is to make sure we connect our nodes for the first company. You use the ID from one node to connect it to another node. By design, when ID for New-DiagramNode is not given, Label becomes ID as well. This means you can skip defining ID and use Labels only; however, this becomes problematic with more complicated labels.
New-DiagramLink -From 'ExchangeCompanyA' -To 'CompanyAAD' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'ExchangeCompanyA' -To 'Internet 2'
New-DiagramLink -From 'Internet1' -To 'CompanyAO365' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'AzureADConnectCompanyA' -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'Internet1' -ArrowsToEnabled
New-DiagramLink -From 'CompanyAO365' -To 'OneDrive' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'SharePoint' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'Teams' -ArrowsToEnabled -ArrowsFromEnabled
While I am not showing that above, New-DiagramLink allows many to many connections, this means you don't have to make each link separate to create complicated structures. In this case, it's not needed, but know it's there. Let's put those defined links to the diagram, shall we?
New-HTML -Online -FilePath $PSScriptRoot\MyDiagram.html {
New-HTMLDiagram {
# Those control layout / physics
New-DiagramOptionsLayout -HierarchicalEnabled $true #-HierarchicalDirection FromLeftToRight
New-DiagramOptionsPhysics -Enabled $true -HierarchicalRepulsionAvoidOverlap 1 -HierarchicalRepulsionNodeDistance 200
# Lets add nodes to the diagram representing Company A
New-DiagramNode -Label "Active Directory`nCompanyADawid.Local" -Id 'CompanyAAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyADawid.Local" -Id 'AzureADConnectCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label "Exchange`nCompanyADawid.local" -Id 'ExchangeCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-2-569302.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet1' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyALTD.onmicrosoft.com' -Id 'CompanyAO365' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Level 1
New-DiagramNode -Label 'OneDrive' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'Teams' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'SharePoint' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
# Lets add nodes to the diagram representing Company B
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet2' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyBSA.onmicrosoft.com' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Id 'CompanyBO365' -Level 1
New-DiagramNode -Label "Active Directory`nCompanyB.corp" -Id 'CompanyBAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyB.corp" -Id 'AzureADConnectCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Exchange Online' -Id 'ExchangeCompanyB' -ImageType squareImage -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-4-896276.png' -Level 0
New-DiagramNode -Label "OneDrive`nCompanyB" -Id 'OneDriveCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "Teams`nCompanyB" -Id 'TeamsCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "SharePoint`nCompanyB" -Id 'SharePointCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
# Company 1 -Connections
New-DiagramLink -From 'ExchangeCompanyA' -To 'CompanyAAD' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'ExchangeCompanyA' -To 'Internet 2'
New-DiagramLink -From 'Internet1' -To 'CompanyAO365' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'AzureADConnectCompanyA' -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'Internet1' -ArrowsToEnabled
New-DiagramLink -From 'CompanyAO365' -To 'OneDrive' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'SharePoint' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'Teams' -ArrowsToEnabled -ArrowsFromEnabled
}
} -ShowHTML
In the next step, we do the same thing as above – connect all the nodes for the second company.
New-HTML -Online -FilePath $PSScriptRoot\MyDiagram.html {
New-HTMLDiagram {
# Those control layout / physics
New-DiagramOptionsLayout -HierarchicalEnabled $true #-HierarchicalDirection FromLeftToRight
New-DiagramOptionsPhysics -Enabled $true -HierarchicalRepulsionAvoidOverlap 1 -HierarchicalRepulsionNodeDistance 200
# Lets add nodes to the diagram representing Company A
New-DiagramNode -Label "Active Directory`nCompanyADawid.Local" -Id 'CompanyAAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyADawid.Local" -Id 'AzureADConnectCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label "Exchange`nCompanyADawid.local" -Id 'ExchangeCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-2-569302.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet1' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyALTD.onmicrosoft.com' -Id 'CompanyAO365' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Level 1
New-DiagramNode -Label 'OneDrive' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'Teams' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'SharePoint' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
# Lets add nodes to the diagram representing Company B
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet2' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyBSA.onmicrosoft.com' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Id 'CompanyBO365' -Level 1
New-DiagramNode -Label "Active Directory`nCompanyB.corp" -Id 'CompanyBAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyB.corp" -Id 'AzureADConnectCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Exchange Online' -Id 'ExchangeCompanyB' -ImageType squareImage -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-4-896276.png' -Level 0
New-DiagramNode -Label "OneDrive`nCompanyB" -Id 'OneDriveCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "Teams`nCompanyB" -Id 'TeamsCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "SharePoint`nCompanyB" -Id 'SharePointCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
# Company 1 -Connections
New-DiagramLink -From 'ExchangeCompanyA' -To 'CompanyAAD' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'ExchangeCompanyA' -To 'Internet 2'
New-DiagramLink -From 'Internet1' -To 'CompanyAO365' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'AzureADConnectCompanyA' -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'Internet1' -ArrowsToEnabled
New-DiagramLink -From 'CompanyAO365' -To 'OneDrive' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'SharePoint' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'Teams' -ArrowsToEnabled -ArrowsFromEnabled
# Company 2 - Connections
New-DiagramLink -From "ExchangeCompanyB" -To 'CompanyBO365'
New-DiagramLink -From "CompanyBData" -To 'CompanyBO365'
New-DiagramLink -From 'CompanyBAD' -To 'AzureADConnectCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBAD' -To 'Internet2' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'Internet2' -To 'CompanyBO365' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBO365' -To 'OneDriveCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBO365' -To 'SharePointCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBO365' -To 'TeamsCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
}
} -ShowHTML
As you can see, we now have two separate company infrastructures. Those are similar, but with some differences. Now let's connect those two companies with a link to the Internet.
New-HTML -Online -FilePath $PSScriptRoot\MyDiagram.html {
New-HTMLDiagram {
# Those control layout / physics
New-DiagramOptionsLayout -HierarchicalEnabled $true #-HierarchicalDirection FromLeftToRight
New-DiagramOptionsPhysics -Enabled $true -HierarchicalRepulsionAvoidOverlap 1 -HierarchicalRepulsionNodeDistance 200
# Lets add nodes to the diagram representing Company A
New-DiagramNode -Label "Active Directory`nCompanyADawid.Local" -Id 'CompanyAAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyADawid.Local" -Id 'AzureADConnectCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label "Exchange`nCompanyADawid.local" -Id 'ExchangeCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-2-569302.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet1' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyALTD.onmicrosoft.com' -Id 'CompanyAO365' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Level 1
New-DiagramNode -Label 'OneDrive' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'Teams' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'SharePoint' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
# Lets add nodes to the diagram representing Company B
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet2' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyBSA.onmicrosoft.com' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Id 'CompanyBO365' -Level 1
New-DiagramNode -Label "Active Directory`nCompanyB.corp" -Id 'CompanyBAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyB.corp" -Id 'AzureADConnectCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Exchange Online' -Id 'ExchangeCompanyB' -ImageType squareImage -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-4-896276.png' -Level 0
New-DiagramNode -Label "OneDrive`nCompanyB" -Id 'OneDriveCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "Teams`nCompanyB" -Id 'TeamsCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "SharePoint`nCompanyB" -Id 'SharePointCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
# Company 1 -Connections
New-DiagramLink -From 'ExchangeCompanyA' -To 'CompanyAAD' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'ExchangeCompanyA' -To 'Internet 2'
New-DiagramLink -From 'Internet1' -To 'CompanyAO365' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'AzureADConnectCompanyA' -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'Internet1' -ArrowsToEnabled
New-DiagramLink -From 'CompanyAO365' -To 'OneDrive' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'SharePoint' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'Teams' -ArrowsToEnabled -ArrowsFromEnabled
# Company 2 - Connections
New-DiagramLink -From "ExchangeCompanyB" -To 'CompanyBO365'
New-DiagramLink -From "CompanyBData" -To 'CompanyBO365'
New-DiagramLink -From 'CompanyBAD' -To 'AzureADConnectCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBAD' -To 'Internet2' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'Internet2' -To 'CompanyBO365' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBO365' -To 'OneDriveCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBO365' -To 'SharePointCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBO365' -To 'TeamsCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
# Lets connect Internets together
New-DiagramLink -From 'Internet1' -To 'Internet2' -Label 'VPN Connection' -Color Blue -Dashes
}
} -ShowHTML
Isn't it cool? By default, when creating New-HTMLDiagram, the diagram height is 400px, and the width takes up 100% of the width of the container it is in. This makes sure diagram resizes itself correctly when it's part of a larger structure on the HTML page, as PSWriteHTML offers a bunch of features such as Tables, Charts, OrgCharts, Wizards and many many more that allow you to not only create diagram, but make it really interactive for the end user. While width automatically resizes itself, height does not. If you're playing with a diagram and would like the diagram to fit a visible part of your browser (be it a small laptop screen or a huge 49-inch monitor you can use magic value 100vh to make sure your diagram fits perfectly.
New-HTML -Online -FilePath $PSScriptRoot\MyDiagram.html {
New-HTMLDiagram {
# Those control layout / physics
New-DiagramOptionsLayout -HierarchicalEnabled $true #-HierarchicalDirection FromLeftToRight
New-DiagramOptionsPhysics -Enabled $true -HierarchicalRepulsionAvoidOverlap 1 -HierarchicalRepulsionNodeDistance 200
# Lets add nodes to the diagram representing Company A
New-DiagramNode -Label "Active Directory`nCompanyADawid.Local" -Id 'CompanyAAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyADawid.Local" -Id 'AzureADConnectCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label "Exchange`nCompanyADawid.local" -Id 'ExchangeCompanyA' -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-2-569302.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet1' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyALTD.onmicrosoft.com' -Id 'CompanyAO365' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Level 1
New-DiagramNode -Label 'OneDrive' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'Teams' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label 'SharePoint' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
# Lets add nodes to the diagram representing Company B
New-DiagramNode -Label 'Internet' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/internet-2102080-1768387.png' -ImageType squareImage -Id 'Internet2' -Level 2
New-DiagramNode -Label 'Office 365 - CompanyBSA.onmicrosoft.com' -ImageType circularImage -Image 'https://cdn.iconscout.com/icon/free/png-64/office-365-1482123-1254388.png' -Id 'CompanyBO365' -Level 1
New-DiagramNode -Label "Active Directory`nCompanyB.corp" -Id 'CompanyBAD' -Image 'https://cdn.iconscout.com/icon/premium/png-64-thumb/active-directory-1830982-1554160.png' -ImageType squareImage -Level 3
New-DiagramNode -Label "Azure AD Connect`nCompanyB.corp" -Id 'AzureADConnectCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/azure-190760.png' -ImageType squareImage -Level 4
New-DiagramNode -Label 'Exchange Online' -Id 'ExchangeCompanyB' -ImageType squareImage -Image 'https://cdn.iconscout.com/icon/free/png-64/microsoft-exchange-4-896276.png' -Level 0
New-DiagramNode -Label "OneDrive`nCompanyB" -Id 'OneDriveCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/onedrive-1411856-1194345.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "Teams`nCompanyB" -Id 'TeamsCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/teams-1411850-1194339.png' -ImageType squareImage -Level 0
New-DiagramNode -Label "SharePoint`nCompanyB" -Id 'SharePointCompanyB' -Image 'https://cdn.iconscout.com/icon/free/png-64/sharepoint-1411852-1194341.png' -ImageType squareImage -Level 0
# Company 1 -Connections
New-DiagramLink -From 'ExchangeCompanyA' -To 'CompanyAAD' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'ExchangeCompanyA' -To 'Internet 2'
New-DiagramLink -From 'Internet1' -To 'CompanyAO365' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'AzureADConnectCompanyA' -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAAD' -To 'Internet1' -ArrowsToEnabled
New-DiagramLink -From 'CompanyAO365' -To 'OneDrive' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'SharePoint' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyAO365' -To 'Teams' -ArrowsToEnabled -ArrowsFromEnabled
# Company 2 - Connections
New-DiagramLink -From "ExchangeCompanyB" -To 'CompanyBO365'
New-DiagramLink -From "CompanyBData" -To 'CompanyBO365'
New-DiagramLink -From 'CompanyBAD' -To 'AzureADConnectCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBAD' -To 'Internet2' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'Internet2' -To 'CompanyBO365' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBO365' -To 'OneDriveCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBO365' -To 'SharePointCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
New-DiagramLink -From 'CompanyBO365' -To 'TeamsCompanyB' -ArrowsToEnabled -ArrowsFromEnabled
# Lets connect Internets together
New-DiagramLink -From 'Internet1' -To 'Internet2' -Label 'VPN Connection' -Color Blue -Dashes
} -Height '100vh'
} -ShowHTML
In my case, the diagram positioned itself in the middle of the screen, leaving some whitespace around the top and bottom. The Height parameter in New-HTMLDiagram can take multiple different values. It can be in calc(100vh-20px) or 800px or any other valid HTML value for size. Depending on your end goal, you will need to experiment with what suits you better.