<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8463146875506159962</id><updated>2026-07-18T01:49:05.064-04:00</updated><category term="powershell"/><category term="VMware"/><category term="active"/><category term="directory"/><category term="shell"/><category term="power"/><category term="windows"/><category term="user"/><category term="job"/><category term="Netapp"/><category term="VM"/><category term="ad"/><category term="all"/><category term="audit"/><category term="domain"/><category term="Active Directory"/><category term="batch"/><category term="group"/><category term="log"/><category term="permissions"/><category term="runas"/><category term="script"/><category term="users"/><category term="2008"/><category term="OS"/><category term="Tech"/><category term="accounts"/><category term="certificate"/><category term="drive"/><category term="esxi"/><category term="excel"/><category term="flash"/><category term="host"/><category term="jobs"/><category term="password"/><category term="r2"/><category term="run as"/><category term="service"/><category term="shares"/><category term="solidcore"/><category term="usb"/><category term="10"/><category term="2010"/><category term="2012"/><category term="ActiveDirectory"/><category term="Get"/><category term="Get-ADComputer"/><category term="Name"/><category term="acl"/><category term="administrator"/><category term="application"/><category term="application control"/><category term="change control"/><category term="command"/><category term="console"/><category term="core"/><category term="csv"/><category term="days"/><category term="disable"/><category term="disk"/><category term="esx"/><category term="export-csv"/><category term="get-aduser"/><category term="line"/><category term="liner"/><category term="management"/><category term="menu"/><category term="microsoft"/><category term="multiple"/><category term="on"/><category term="one"/><category term="parse"/><category term="rdp"/><category term="remote"/><category term="route"/><category term="server"/><category term="servers"/><category term="services"/><category term="share"/><category term="solid"/><category term="space"/><category term="sql"/><category term="start"/><category term="system"/><category term="time"/><category term="total"/><category term="touchscreen"/><category term="vb.net"/><category term="vb.net 2010"/><category term="0x80246007"/><category term="19"/><category term="2003"/><category term="2005"/><category term="5"/><category term="5.1"/><category term="6"/><category term="6.0"/><category term="6.3.9600.17667"/><category term="7"/><category term="9879"/><category term="ADDS"/><category term="API"/><category term="CALLs"/><category term="COMAdmin"/><category term="COMAdminCatalog"/><category term="DNS"/><category term="Get-Acl"/><category term="KQL"/><category term="NTP"/><category term="New-WebServiceProxy"/><category term="Object"/><category term="RequestPolicy.inf"/><category term="SAN"/><category term="Set"/><category term="Touch Screen"/><category term="account"/><category term="adcs"/><category term="add"/><category term="adfs"/><category term="agent"/><category term="another"/><category term="as"/><category term="azure"/><category term="backtrack"/><category term="balance"/><category term="basic"/><category term="beta"/><category term="bit"/><category term="block"/><category term="blue"/><category term="book"/><category term="bug"/><category term="calendar"/><category term="can&#39;t"/><category term="cert"/><category term="certutil"/><category term="cf-29"/><category term="change"/><category term="cifs"/><category term="click"/><category term="client"/><category term="cluster"/><category term="com"/><category term="com+"/><category term="commandline"/><category term="configuration"/><category term="control"/><category term="controller"/><category term="copy"/><category term="counter"/><category term="counters"/><category term="cpu"/><category term="csr"/><category term="css"/><category term="dataontap"/><category term="datastore"/><category term="date"/><category term="del"/><category term="delete"/><category term="dell"/><category term="denied"/><category term="dhcp"/><category term="different"/><category term="distinguishedname"/><category term="dynamic buttons"/><category term="email"/><category term="empty"/><category term="enable"/><category term="encryption"/><category term="eperm"/><category term="evc"/><category term="event"/><category term="expiration"/><category term="expiration date"/><category term="expire"/><category term="expires"/><category term="explorer"/><category term="explorer.exe"/><category term="extract"/><category term="faulting"/><category term="filer"/><category term="files"/><category term="folder"/><category term="for"/><category term="forfiles"/><category term="forfiles.exe"/><category term="free"/><category term="fsmo"/><category term="generate"/><category term="get-msoluser"/><category term="get-navfiler"/><category term="get-navol"/><category term="give"/><category term="gpo"/><category term="graph"/><category term="groups"/><category term="gui"/><category term="handle"/><category term="hard"/><category term="hardware"/><category term="hash"/><category term="highlight"/><category term="how"/><category term="http://xserv.dell.com/services/AssetService.asmx?WSDL"/><category term="id"/><category term="identityreference"/><category term="installation"/><category term="intel"/><category term="interface"/><category term="inventory"/><category term="ip"/><category term="iphash"/><category term="javascript"/><category term="lan"/><category term="last"/><category term="leak"/><category term="linux"/><category term="list"/><category term="load"/><category term="local"/><category term="login"/><category term="logon"/><category term="lookup"/><category term="lun"/><category term="macro"/><category term="mail"/><category term="map"/><category term="mappings"/><category term="mass"/><category term="max"/><category term="mcafee"/><category term="memory"/><category term="metadata"/><category term="migrate"/><category term="mode"/><category term="model"/><category term="module"/><category term="move"/><category term="multi"/><category term="multihomed"/><category term="na"/><category term="network"/><category term="never"/><category term="new"/><category term="nfs"/><category term="node.js"/><category term="ntfs"/><category term="number"/><category term="off"/><category term="old"/><category term="older"/><category term="open"/><category term="ox80073cff"/><category term="passwordneverexpires"/><category term="path"/><category term="pen"/><category term="people"/><category term="performance"/><category term="pi"/><category term="ping"/><category term="pinging"/><category term="policy"/><category term="port"/><category term="powered"/><category term="powerhshell"/><category term="primary"/><category term="principal"/><category term="print"/><category term="processstartinfo"/><category term="production"/><category term="protection"/><category term="ps1"/><category term="raspberry"/><category term="raspi-config"/><category term="raw"/><category term="rdm"/><category term="recycle"/><category term="regedit"/><category term="relay"/><category term="replication"/><category term="report"/><category term="requirements"/><category term="reserve"/><category term="right"/><category term="role"/><category term="run"/><category term="runtime"/><category term="scope"/><category term="scopeid"/><category term="scopeoptions"/><category term="screen"/><category term="search"/><category term="securestring"/><category term="security"/><category term="send"/><category term="serial"/><category term="services.msc"/><category term="set-aduser"/><category term="set-msoluser"/><category term="shot"/><category term="single"/><category term="snap"/><category term="source"/><category term="sp1"/><category term="studio"/><category term="subnet"/><category term="sys"/><category term="syslog"/><category term="ten"/><category term="than"/><category term="tool"/><category term="touch"/><category term="tough"/><category term="toughbook"/><category term="unknown"/><category term="update"/><category term="upn"/><category term="userprincipalname"/><category term="utility"/><category term="v-filer"/><category term="vba"/><category term="vbs"/><category term="vcenter"/><category term="vfiler"/><category term="video"/><category term="vmware_hostclient_logs"/><category term="volume"/><category term="vsa"/><category term="vsphere"/><category term="vswitch"/><category term="warranty"/><category term="wheezy"/><category term="wifi"/><category term="win"/><category term="windows\system32\drivers\etc\hosts"/><category term="winzip"/><category term="without"/><category term="wmi"/><category term="works"/><category term="workstation"/><category term="wrapper"/><category term="write"/><category term="wrong"/><category term="x"/><title type='text'>Just Notes</title><subtitle type='html'>These are just random notes and programs that may have incomplete descriptions. Any scripts or programs use at your risk&#xa;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.tonyunger.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>88</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-1557149280962448541</id><published>2025-09-02T10:19:00.002-04:00</published><updated>2025-09-02T10:19:12.029-04:00</updated><title type='text'>Powershell: Microsoft Graph to add new roles to application registration </title><content type='html'>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
    &lt;link href=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/themes/prism-tomorrow.min.css&quot; rel=&quot;stylesheet&quot; /&gt;
    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/prism.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-powershell.min.js&quot;&gt;&lt;/script&gt;
    &lt;title&gt;PowerShell Script&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
 &lt;pre&gt;
 Bulk add new roles to application registration in azure. Update $roles with &lt;group&gt;,User
 &lt;/pre&gt;

&lt;pre&gt;&lt;code class=&quot;language-powershell&quot;&gt;# Requires: Microsoft.Graph.Applications module
# Connect to Microsoft Graph with sufficient permissions (e.g., Application.ReadWrite.All)
Connect-MgGraph -scope  &quot;application.readwrite.all&quot; -TenantId &quot;&amp;lt;Tenant-ID&amp;gt;&quot;
# Variables
$AppId = &quot;&amp;lt;App-ID&amp;gt;&quot; # ObjectId of the Azure AD Application

$roles = @&quot;
value,allowedMemberTypes
Group1,User
Group2,User
&quot;@ | ConvertFrom-Csv

$roles = $roles | ForEach-Object {
    [PSCustomObject]@{
        displayName = $_.value
        description = $_.value
        value = $_.value
        allowedMemberTypes = $_.allowedMemberTypes -split &quot;;&quot;
    }
}

# Get the application
$app = Get-MgApplication -ApplicationId $AppId

# Add new roles 
$newRoles = @()
foreach ($role in $roles) {
    $appRole = [Microsoft.Graph.PowerShell.Models.MicrosoftGraphAppRole]::new()
    $appRole.Id = [guid]::NewGuid()
    $appRole.DisplayName = $role.displayName
    $appRole.Description = $role.description
    $appRole.Value = $role.value
    $appRole.AllowedMemberTypes = $role.allowedMemberTypes
    $appRole.IsEnabled = $true
    $appRole.Origin = &quot;Application&quot;
    $newRoles += $appRole
}

# Combine existing roles
$allRoles = @($app.AppRoles) + $newRoles

Update-MgApplication -ApplicationId $AppId -AppRoles $allRoles

Write-Host &quot;Roles added successfully.&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;/body&gt;
&lt;/html&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/1557149280962448541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2025/09/powershell-microsoft-graph-to-add-new.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/1557149280962448541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/1557149280962448541'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2025/09/powershell-microsoft-graph-to-add-new.html' title='Powershell: Microsoft Graph to add new roles to application registration '/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-7431954790593643184</id><published>2025-03-30T10:17:00.004-04:00</published><updated>2025-03-30T10:17:58.223-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="active"/><category scheme="http://www.blogger.com/atom/ns#" term="ADDS"/><category scheme="http://www.blogger.com/atom/ns#" term="audit"/><category scheme="http://www.blogger.com/atom/ns#" term="directory"/><category scheme="http://www.blogger.com/atom/ns#" term="group"/><category scheme="http://www.blogger.com/atom/ns#" term="KQL"/><category scheme="http://www.blogger.com/atom/ns#" term="Object"/><title type='text'>KQL - Group Object Audits ADDS</title><content type='html'>&lt;pre&gt;
This is a KQL written for Azure Sentinel. 
Purpose is to search for eventid from Active Directory Domain Services related to Group objects.
&lt;/pre&gt;

&lt;pre style=&quot;background-color: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto; font-family: Consolas, monospace; line-height: 1.5;&quot;&gt;
&lt;code&gt;
&lt;span style=&quot;color: #0000FF;&quot;&gt;SecurityEvent&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;| where&lt;/span&gt; &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;in&lt;/span&gt; (4728, 4729, 4732, 4733, 4756, 4757, 4727, 4730, 4731, 4734) &lt;span style=&quot;color: #808080;&quot;&gt;// Add or remove from group, create or delete group&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;| extend&lt;/span&gt; 
    &lt;span style=&quot;color: #800080;&quot;&gt;Action&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;case&lt;/span&gt;(
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4728, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Added to Global Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4729, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Removed from Global Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4732, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Added to Local Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4733, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Removed from Local Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4756, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Added to Universal Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4757, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Removed from Universal Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4727, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Created a Security-Enabled Global Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4730, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Deleted a Security-Enabled Global Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4731, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Created a Security-Enabled Local Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt; == 4734, &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Deleted a Security-Enabled Local Group&quot;&lt;/span&gt;,
        &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Unknown Action&quot;&lt;/span&gt;
    ),
    &lt;span style=&quot;color: #800080;&quot;&gt;Initiator&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;coalesce&lt;/span&gt;(&lt;span style=&quot;color: #0000FF;&quot;&gt;tostring&lt;/span&gt;(&lt;span style=&quot;color: #800080;&quot;&gt;SubjectUserName&lt;/span&gt;), &lt;span style=&quot;color: #0000FF;&quot;&gt;tostring&lt;/span&gt;(&lt;span style=&quot;color: #800080;&quot;&gt;AccountName&lt;/span&gt;), &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Unknown Initiator&quot;&lt;/span&gt;)
&lt;span style=&quot;color: #008000;&quot;&gt;| summarize&lt;/span&gt; 
    &lt;span style=&quot;color: #800080;&quot;&gt;FirstOccurrence&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;min&lt;/span&gt;(&lt;span style=&quot;color: #800080;&quot;&gt;TimeGenerated&lt;/span&gt;)    
    &lt;span style=&quot;color: #008000;&quot;&gt;by&lt;/span&gt; &lt;span style=&quot;color: #800080;&quot;&gt;Action&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;TargetGroup&lt;/span&gt; = &lt;span style=&quot;color: #800080;&quot;&gt;TargetAccount&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;Initiator&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;Domain&lt;/span&gt; = &lt;span style=&quot;color: #800080;&quot;&gt;TargetDomainName&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;MemberName&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;| project&lt;/span&gt; &lt;span style=&quot;color: #800080;&quot;&gt;FirstOccurrence&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;Action&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;Initiator&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;Domain&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;TargetGroup&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;MemberName&lt;/span&gt;, &lt;span style=&quot;color: #800080;&quot;&gt;EventID&lt;/span&gt;
&lt;/code&gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/7431954790593643184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2025/03/kql-group-object-audits-adds.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/7431954790593643184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/7431954790593643184'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2025/03/kql-group-object-audits-adds.html' title='KQL - Group Object Audits ADDS'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-1191175823491644775</id><published>2025-03-30T10:07:00.007-04:00</published><updated>2025-03-30T10:19:06.092-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="audit"/><category scheme="http://www.blogger.com/atom/ns#" term="batch"/><category scheme="http://www.blogger.com/atom/ns#" term="graph"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="user"/><title type='text'>Powershell - Search Azure/Entra AD for current status of an employeeID accounts using Graph Batch</title><content type='html'>&lt;pre&gt;
Graph is a pain to work with if you are like me and just a scripter 

Takes a list of employee IDs via the $employeeIDs variable 
Queries Azure AD via Microsoft Graph in batches of 20
Retrieves userPrincipalName, employeeId, accountEnabled, 
and LastPasswordChangeDateTime
Outputs results to console and CSV
&lt;/pre&gt;

&lt;pre style=&quot;background-color: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto;&quot;&gt;
&lt;code style=&quot;font-family: Consolas, monospace;&quot;&gt;
Connect-MgGraph -Scopes &quot;User.Read.All&quot;

$employeeIds = @&quot;
EMPID
0000001
&quot;@ | ConvertFrom-Csv

$employeeIds = $employeeIds.empid   

# Create batch request body
$batchRequests = @()
$batchSize = 20  # Microsoft Graph allows up to 20 requests per batch
$idCounter = 1

for ($i = 0; $i -lt $employeeIds.Count; $i++) {
    $request = @{
        &quot;id&quot; = &quot;$idCounter&quot;
        &quot;method&quot; = &quot;GET&quot;
        &quot;url&quot; = &quot;/users?`$filter=employeeId eq &#39;$($employeeIds[$i])&#39;&amp;`$select=userPrincipalName,employeeId,accountEnabled,LastPasswordChangeDateTime&quot;
    }
    $batchRequests += $request
    $idCounter++
}

# Split into batches of 20 which i believe is the limit 
$batchedResults = @()
for ($i = 0; $i -lt $batchRequests.Count; $i += $batchSize) {
    $batchEnd = [Math]::Min($i + $batchSize, $batchRequests.Count)
    $currentBatch = $batchRequests[$i..($batchEnd-1)]
    
    $batchBody = @{
        &quot;requests&quot; = $currentBatch
    } | ConvertTo-Json -Depth 10

    # Send batch request
    $response = Invoke-MgGraphRequest -Method POST -Uri &quot;https://graph.microsoft.com/v1.0/`$batch&quot; -Body $batchBody
    
    # Process responses
    foreach ($resp in $response.responses) {
        if ($resp.status -eq 200 -and $resp.body.value) {
            $batchedResults += $resp.body.value | Select-Object @{
                Name = &quot;UserPrincipalName&quot;; Expression = {$_.userPrincipalName}
            }, @{
                Name = &quot;EmployeeID&quot;; Expression = {$_.employeeId}
            }, @{
                Name = &quot;AccountEnabled&quot;; Expression = {$_.accountEnabled}
            }, @{
                Name = &quot;LastPasswordChangeDateTime&quot;; Expression = {$_.LastPasswordChangeDateTime}
            }
        }
    }
}

#Tesults
$batchedResults | Format-Table -AutoSize
$batchedResults | Export-Csv -Path &quot;C:\AzureAD_Employee_Search.csv&quot; -NoTypeInformation
&lt;/code&gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/1191175823491644775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2025/03/search-azureentra-ad-for-current-status.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/1191175823491644775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/1191175823491644775'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2025/03/search-azureentra-ad-for-current-status.html' title='Powershell - Search Azure/Entra AD for current status of an employeeID accounts using Graph Batch'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-758760360704881377</id><published>2024-09-20T14:21:00.005-04:00</published><updated>2025-03-30T10:22:07.776-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="event"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="remote"/><category scheme="http://www.blogger.com/atom/ns#" term="windows"/><title type='text'>Powershell: Read windows event log remotely and write to csv</title><content type='html'>&lt;pre style=&quot;background-color: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto; font-family: Consolas, monospace; line-height: 1.5;&quot;&gt;
&lt;code&gt;
&lt;span style=&quot;color: #808080;&quot;&gt;#reads event logs for filter and exports to&lt;/span&gt;

&lt;span style=&quot;color: #800080;&quot;&gt;$Date&lt;/span&gt; = (&lt;span style=&quot;color: #0000FF;&quot;&gt;Get-Date&lt;/span&gt;).AddMinutes(-30)

&lt;span style=&quot;color: #800080;&quot;&gt;$LogName&lt;/span&gt; = &lt;span style=&quot;color: #A31515;&quot;&gt;&#39;Security&#39;&lt;/span&gt;

&lt;span style=&quot;color: #800080;&quot;&gt;$ProviderName&lt;/span&gt; = &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Microsoft-Windows-Security-Auditing&quot;&lt;/span&gt;

&lt;span style=&quot;color: #800080;&quot;&gt;$EventID&lt;/span&gt;  = 6273

&lt;span style=&quot;color: #800080;&quot;&gt;$computer&lt;/span&gt; = &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;server.microsoft.com&quot;&lt;/span&gt;

&lt;span style=&quot;color: #0000FF;&quot;&gt;Write-Output&lt;/span&gt; &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;Searching $computer&quot;&lt;/span&gt;

&lt;span style=&quot;color: #800080;&quot;&gt;$Events&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;Get-WinEvent&lt;/span&gt; -ComputerName &lt;span style=&quot;color: #800080;&quot;&gt;$computer&lt;/span&gt; -FilterHashtable @{
    &lt;span style=&quot;color: #800080;&quot;&gt;LogName&lt;/span&gt; = &lt;span style=&quot;color: #800080;&quot;&gt;$LogName&lt;/span&gt;
    &lt;span style=&quot;color: #800080;&quot;&gt;ProviderName&lt;/span&gt; = &lt;span style=&quot;color: #800080;&quot;&gt;$ProviderName&lt;/span&gt;
    &lt;span style=&quot;color: #800080;&quot;&gt;Id&lt;/span&gt; = &lt;span style=&quot;color: #800080;&quot;&gt;$EventID&lt;/span&gt;
    &lt;span style=&quot;color: #800080;&quot;&gt;StartTime&lt;/span&gt; = &lt;span style=&quot;color: #800080;&quot;&gt;$Date&lt;/span&gt;
}

&lt;span style=&quot;color: #800080;&quot;&gt;$report&lt;/span&gt; = @()

&lt;span style=&quot;color: #800080;&quot;&gt;$Events&lt;/span&gt; | &lt;span style=&quot;color: #008000;&quot;&gt;ForEach-Object&lt;/span&gt; -Process {
    [&lt;span style=&quot;color: #0000FF;&quot;&gt;xml&lt;/span&gt;]&lt;span style=&quot;color: #800080;&quot;&gt;$ConvertedFromXML&lt;/span&gt; = &lt;span style=&quot;color: #800080;&quot;&gt;$_&lt;/span&gt;.ToXml()
    &lt;span style=&quot;color: #800080;&quot;&gt;$params&lt;/span&gt; = @{} 

    &lt;span style=&quot;color: #008000;&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color: #800080;&quot;&gt;$entry&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #800080;&quot;&gt;$ConvertedFromXML&lt;/span&gt;.Event.EventData.Data) {
        &lt;span style=&quot;color: #800080;&quot;&gt;$name&lt;/span&gt; = &lt;span style=&quot;color: #800080;&quot;&gt;$entry&lt;/span&gt;.Name
        &lt;span style=&quot;color: #800080;&quot;&gt;$Value&lt;/span&gt; = &lt;span style=&quot;color: #800080;&quot;&gt;$entry&lt;/span&gt;.&lt;span style=&quot;color: #A31515;&quot;&gt;&#39;#text&#39;&lt;/span&gt;
        &lt;span style=&quot;color: #800080;&quot;&gt;$params&lt;/span&gt;[&lt;span style=&quot;color: #800080;&quot;&gt;$name&lt;/span&gt;] = &lt;span style=&quot;color: #800080;&quot;&gt;$Value&lt;/span&gt;
    }
    
    &lt;span style=&quot;color: #800080;&quot;&gt;$report&lt;/span&gt; += [&lt;span style=&quot;color: #0000FF;&quot;&gt;pscustomobject&lt;/span&gt;]&lt;span style=&quot;color: #800080;&quot;&gt;$params&lt;/span&gt;
}

&lt;span style=&quot;color: #800080;&quot;&gt;$report&lt;/span&gt; | &lt;span style=&quot;color: #0000FF;&quot;&gt;Export-Csv&lt;/span&gt; -NoTypeInformation -Path &lt;span style=&quot;color: #A31515;&quot;&gt;&quot;C:\Temp\Events.csv&quot;&lt;/span&gt;
&lt;/code&gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/758760360704881377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2024/09/powershell-read-event-log-remotely-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/758760360704881377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/758760360704881377'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2024/09/powershell-read-event-log-remotely-and.html' title='Powershell: Read windows event log remotely and write to csv'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-8604281194975912504</id><published>2023-08-15T06:21:00.007-04:00</published><updated>2023-08-15T06:33:51.808-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="click"/><category scheme="http://www.blogger.com/atom/ns#" term="css"/><category scheme="http://www.blogger.com/atom/ns#" term="disable"/><category scheme="http://www.blogger.com/atom/ns#" term="highlight"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="protection"/><category scheme="http://www.blogger.com/atom/ns#" term="right"/><title type='text'>Websites that disable right click and highlight bypass</title><content type='html'>&lt;pre&gt;
Using Google Chrome or MS Edge:

Disable Javascript post page load.
1. Open console in dev tools
2. press ctrl - alt - p
3. In the run dialog blox type in javascript and select 
&quot;Disable Javascript&quot;

Disable CSS from loading 
1. Open console in dev tools
2. press ctrl - alt - p
3. In the run dialog box type in &quot;Network request blocking&quot;
4. on the drawer that appears check &quot;Enable Network request blocking&quot;
5. Click the plus button and add pattern
6. type in pattern &quot;*.css&quot;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/8604281194975912504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2023/08/websites-that-disable-right-click-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/8604281194975912504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/8604281194975912504'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2023/08/websites-that-disable-right-click-and.html' title='Websites that disable right click and highlight bypass'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-8382431292787723213</id><published>2023-06-20T07:31:00.005-04:00</published><updated>2023-06-20T07:41:43.409-04:00</updated><title type='text'>Powershell - Microsoft Graph reports - Get MFA status of users.</title><content type='html'>

&lt;div&gt;&lt;span style=&quot;color: blue;&quot;&gt;Requires an App Registration be setup with proper API permissions and a self-signed certificate for authentication to it.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;Import-Module&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;Microsoft.Graph.Reports&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Select-MgProfile&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;-Name&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkred;&quot;&gt;&quot;beta&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orangered;&quot;&gt;$TenantId&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkred;&quot;&gt;&quot;XXXXX&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orangered;&quot;&gt;$AppId&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkred;&quot;&gt;&quot;XXXXX&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Connect-MgGraph&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;-ClientId&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: orangered;&quot;&gt;$AppId&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;-TenantId&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: orangered;&quot;&gt;$TenantId&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;-CertificateThumbprint&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkred;&quot;&gt;&quot;XXXXXXX&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orangered;&quot;&gt;$report&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Get-MgReportCredentialUserRegistrationDetail&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;-all&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orangered;&quot;&gt;$report&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;select&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;@{&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: darkred;&quot;&gt;&quot;AuthMethods&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: orangered;&quot;&gt;$_&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;AuthMethods&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;-join&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkred;&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;IsCapable&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;IsEnabled&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;IsMfaRegistered&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;IsRegistered&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;UserDisplayName&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;UserPrincipalName&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Select&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;UserPrincipalName&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;UserDisplayName&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;IsCapable&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;IsEnabled&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;IsMfaRegistered&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;IsRegistered&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blueviolet;&quot;&gt;AuthMethods&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkgrey;&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;export-csv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;-NoTypeInformation&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;-Path&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: darkred;&quot;&gt;&quot;c:\reports\MFA - MFA Audit Logs.csv&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Disconnect-MgGraph&lt;/span&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/8382431292787723213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2023/06/powershell-microsoft-graph-reports-get.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/8382431292787723213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/8382431292787723213'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2023/06/powershell-microsoft-graph-reports-get.html' title='Powershell - Microsoft Graph reports - Get MFA status of users.'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-6932244272921431581</id><published>2023-06-01T19:33:00.005-04:00</published><updated>2023-06-01T19:34:00.520-04:00</updated><title type='text'>Custom View for Events NTLMv1 on a DC</title><content type='html'>&lt;p&gt;&amp;nbsp;&amp;lt;QueryList&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;lt;Query Id=&quot;0&quot; Path=&quot;Security&quot;&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Select Path=&quot;Security&quot;&amp;gt;*[System[(EventID=4624)] and EventData[Data[@Name=&#39;LmPackageName&#39;]=&#39;NTLM V1&#39;]]&amp;lt;/Select&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;lt;/Query&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;/QueryList&amp;gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/6932244272921431581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2023/06/custom-view-for-events-ntlmv1-on-dc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/6932244272921431581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/6932244272921431581'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2023/06/custom-view-for-events-ntlmv1-on-dc.html' title='Custom View for Events NTLMv1 on a DC'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-947696538081662615</id><published>2023-03-17T16:55:00.004-04:00</published><updated>2023-06-20T07:43:07.593-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DNS"/><title type='text'>Powershell: Get all DNS records from AD DNS</title><content type='html'>
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#006400&#39;&gt;# Load the DNS Server module&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#0000FF&#39;&gt;Import-Module&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8A2BE2&#39;&gt;DnsServer&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&#39;color:#006400&#39;&gt;# Set the output folder&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#FF4500&#39;&gt;$outputFolder&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;=&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;quot;C:\temp\Final&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#FF4500&#39;&gt;$DNSServer&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;=&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#0000FF&#39;&gt;DNSServer.com&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#006400&#39;&gt;# Get all DNS zones&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#FF4500&#39;&gt;$zones&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;=&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#0000FF&#39;&gt;Get-DnsServerZone&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000080&#39;&gt;-ComputerName&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$DNSServer&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&#39;color:#006400&#39;&gt;# Loop through each zone and export its records to a separate CSV file&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#00008B&#39;&gt;foreach&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;(&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$zone&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#00008B&#39;&gt;in&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$zones&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;)&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$records&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;=&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#0000FF&#39;&gt;Get-DnsServerResourceRecord&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000080&#39;&gt;-ZoneName&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$zone&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;ZoneName&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000080&#39;&gt;-ComputerName&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$DNSServer&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;|&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;`&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#0000FF&#39;&gt;select&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8A2BE2&#39;&gt;hostname&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;,&lt;/span&gt;`&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8A2BE2&#39;&gt;recordtype&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;,&lt;/span&gt;`&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8A2BE2&#39;&gt;type&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;,&lt;/span&gt;&lt;span style=&#39;color:#8A2BE2&#39;&gt;timestamp&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;,&lt;/span&gt;`&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8A2BE2&#39;&gt;timetolive&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;,&lt;/span&gt;`&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;@{&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;n&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;=&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;Data&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;e&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;=&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;=&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$_&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;;&lt;/span&gt;`&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#00008B&#39;&gt;switch&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;(&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordType&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;)&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;A&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordData&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;IPv4Address&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;CNAME&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordData&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;HostnameAlias&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;NS&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordData&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;NameServer&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;SOA&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordData&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;PrimaryServer&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;SRV&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordData&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;DomainName&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;PTR&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordData&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;PtrDomainName&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;MX&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordData&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;MailExchange&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;AAAA&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordData&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;IPv6Address&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;#39;TXT&amp;#39;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;{&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$rr&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;RecordData&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;.&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;DescriptiveText&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$outputFile&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;=&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;quot;$outputFolder\$($zone.ZoneName).csv&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$records&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#A9A9A9&#39;&gt;|&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#0000FF&#39;&gt;Export-Csv&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000080&#39;&gt;-NoTypeInformation&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#000080&#39;&gt;-path&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#FF4500&#39;&gt;$outputFile&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#000000&#39;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&#39;color:#006400&#39;&gt;# Output confirmation message&lt;/span&gt;&lt;br /&gt;
&lt;span style=&#39;color:#0000FF&#39;&gt;Write-Host&lt;/span&gt;&lt;span style=&#39;color:#000000&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#39;color:#8B0000&#39;&gt;&amp;quot;DNS records exported to $outputFolder.&amp;quot;&lt;/span&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/947696538081662615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2023/03/powershell-get-all-dns-records-from-ad.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/947696538081662615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/947696538081662615'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2023/03/powershell-get-all-dns-records-from-ad.html' title='Powershell: Get all DNS records from AD DNS'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-4342668895066069589</id><published>2023-02-02T07:22:00.004-05:00</published><updated>2023-02-02T07:34:28.663-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Active Directory"/><category scheme="http://www.blogger.com/atom/ns#" term="dhcp"/><category scheme="http://www.blogger.com/atom/ns#" term="scope"/><category scheme="http://www.blogger.com/atom/ns#" term="scopeid"/><category scheme="http://www.blogger.com/atom/ns#" term="scopeoptions"/><title type='text'>Powershell: AD DHCP scope information</title><content type='html'>&lt;p&gt;Needed a script to export dhcp scope and scope id for a domain.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
  
  
  &lt;pre class=&quot;prettyprint lang-c&quot;&gt;
  
  $report = @()
  $DHCPServer = DHCPServerHostname
  $scopes =Get-DhcpServerv4Scope -ComputerName $DHCPServer
  
  foreach ($scope in $Scopes){
    $scopeID = $scope.ScopeId
    $report += Get-DhcpServerv4OptionValue -ScopeId $scopeID -ComputerName $DHCPServer |`
    select @{name=&quot;ScopeID&quot;;e={$scopeID}},OptionID,Name,Type,@{Name=&quot;Value&quot;;e={$_.value -join &quot;;&quot;}
  }
    
    $report | export-csv -NoTypeInformation -path &quot;c:\temp\DHCPScopeIDwithOption.csv&quot;
    $scopes | export-csv -NoTypeInformation -path &quot;c:\temp\DHCPScopeIDwithMask.csv&quot;

&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/4342668895066069589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2023/02/powershell-ad-dhcp-scope-information.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/4342668895066069589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/4342668895066069589'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2023/02/powershell-ad-dhcp-scope-information.html' title='Powershell: AD DHCP scope information'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-6322659202761068732</id><published>2021-08-09T16:48:00.002-04:00</published><updated>2021-08-09T16:48:18.557-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="adfs"/><category scheme="http://www.blogger.com/atom/ns#" term="certificate"/><category scheme="http://www.blogger.com/atom/ns#" term="extract"/><category scheme="http://www.blogger.com/atom/ns#" term="metadata"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><title type='text'>Powershell - Extract ADFS certificates from ADFS server </title><content type='html'>&lt;p&gt;Wrote script so people specify the adfs server and the signature and encryption certificate will extract the certs to two files stored in c:\temp&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;# just put in the ADFS server name&amp;nbsp;&lt;/p&gt;&lt;p&gt;$AdfsServer = &#39;adfs.microsoft.com&#39;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[xml]$XmlDocument = (New-Object System.Net.WebClient).DownloadString(&quot;https://$AdfsServer/FederationMetadata/2007-06/FederationMetadata.xml&quot;)&lt;/p&gt;&lt;p&gt;#ADFS Signing Certificate&lt;/p&gt;&lt;p&gt;$Cert = $xmldocument.entitydescriptor.roledescriptor.keydescriptor | select Use,@{Name=&quot;x509&quot;; Expression={(($_.keyinfo).X509data).x509certificate}}&lt;/p&gt;&lt;p&gt;#Sign Cert&lt;/p&gt;&lt;p&gt;$cert | ? {$_.use -eq &quot;signing&quot;} | select -ExpandProperty x509 | out-file c:\temp\Signcert.cer&lt;/p&gt;&lt;p&gt;#Encryption Cert&lt;/p&gt;&lt;p&gt;$cert | ? {$_.use -eq &quot;encryption&quot;} | select -ExpandProperty x509 | out-file c:\temp\Encryptioncert.cer&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;$Cert&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/6322659202761068732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2021/08/powershell-extract-adfs-certificates.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/6322659202761068732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/6322659202761068732'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2021/08/powershell-extract-adfs-certificates.html' title='Powershell - Extract ADFS certificates from ADFS server '/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-37949349797017420</id><published>2020-07-29T15:15:00.010-04:00</published><updated>2021-02-13T08:31:01.037-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="certificate"/><title type='text'>Powershell - Get certificate information</title><content type='html'>&lt;p&gt;&amp;nbsp;List Certificate Templates&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-c&quot;&gt;


function&lt;/span&gt; get-CertificateTemplates {
[&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;CmdletBinding&lt;/span&gt;()] &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;Param&lt;/span&gt; (
     [&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;Parameter&lt;/span&gt;(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;Mandatory&lt;/span&gt; = $True, &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;ValueFromPipelineByPropertyName&lt;/span&gt; = $True)]
     [string]$forest
    )
$DefaultPartition = Get-ADDomainController -Server $forest | select -expand DefaultPartition


$configcontext = &lt;span style=&quot;color: blue;&quot;&gt;&quot;CN=Configuration,$(&lt;/span&gt;&lt;span style=&quot;background-color: #e3d2d2; color: #a61717;&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DefaultPartition)&quot;&lt;/span&gt;
$ADSI = [ADSI]&lt;span style=&quot;color: blue;&quot;&gt;&quot;LDAP://CN=Certificate Templates,CN=Public Key Services,CN=Services,$ConfigContext&quot;&lt;/span&gt;

$ADSI.Children | Sort-Object Name | Select-Object DisplayName, Name, msPKI-Cert-Template-OID
}


List Certificate CDP info

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;function&lt;/span&gt; get-CertificateCDP {
[&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;CmdletBinding&lt;/span&gt;()] &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;Param&lt;/span&gt; (
     [&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;Parameter&lt;/span&gt;(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;Mandatory&lt;/span&gt; = $True, &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;ValueFromPipelineByPropertyName&lt;/span&gt; = $True)]
     [string]$forest
    )

$DefaultPartition = Get-ADDomainController -Server $forest | select -expand DefaultPartition


$configcontext = &lt;span style=&quot;color: blue;&quot;&gt;&quot;CN=Configuration,$(&lt;/span&gt;&lt;span style=&quot;background-color: #e3d2d2; color: #a61717;&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DefaultPartition)&quot;&lt;/span&gt;
$ADSI = [ADSI]&lt;span style=&quot;color: blue;&quot;&gt;&quot;LDAP://CN=cdp,CN=Public Key Services,CN=Services,$ConfigContext&quot;&lt;/span&gt;

$ADSI.Children  | select cn,Children,path
}

List Certificate Auhtorities &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;in&lt;/span&gt; forest - requires activedirectory module

&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;function&lt;/span&gt; get-CertificationAuthorities {
[&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;CmdletBinding&lt;/span&gt;()] &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;Param&lt;/span&gt; (
     [&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;Parameter&lt;/span&gt;(&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;Mandatory&lt;/span&gt; = $True, &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;ValueFromPipelineByPropertyName&lt;/span&gt; = $True)]
     [string]$forest
    )
  

$DefaultPartition = Get-ADDomainController -Server $forest | select -expand DefaultPartition


$configcontext = &lt;span style=&quot;color: blue;&quot;&gt;&quot;CN=Configuration,$(&lt;/span&gt;&lt;span style=&quot;background-color: #e3d2d2; color: #a61717;&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DefaultPartition)&quot;&lt;/span&gt;
$ADSI = [ADSI]&lt;span style=&quot;color: blue;&quot;&gt;&quot;LDAP://CN=Certification Authorities,CN=Public Key Services,CN=Services,$ConfigContext&quot;&lt;/span&gt;

$ADSI.Children | select name,whenCreated

} &lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/37949349797017420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2020/07/powershell-get-certificate-information.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/37949349797017420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/37949349797017420'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2020/07/powershell-get-certificate-information.html' title='Powershell - Get certificate information'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-1222909922421349102</id><published>2020-06-29T17:08:00.006-04:00</published><updated>2021-02-13T08:33:23.045-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="active"/><category scheme="http://www.blogger.com/atom/ns#" term="controller"/><category scheme="http://www.blogger.com/atom/ns#" term="directory"/><category scheme="http://www.blogger.com/atom/ns#" term="domain"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="replication"/><category scheme="http://www.blogger.com/atom/ns#" term="report"/><title type='text'>Powershell : get-ADReplicationReport - Function to get replication status from specified domain controller</title><content type='html'>&lt;pre class=&quot;prettyprint lang-c&quot;&gt;

.Synopsis
   Get Active Directory replication report
DESCRIPTION
   reports on replication issues
EXAMPLE
   get-ADReplicationReport -domains &quot;Domain1&quot;,&quot;Domain2&quot;

function get-QrgADReplicationReport
{
    [CmdletBinding()]
    [Alias()]
    [OutputType([int])]
    Param
    (
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        [string]$Server
        
    )

    Begin
    {
    
    }
    Process
    {
    
        Get-ADReplicationPartnerMetadata -Target $server -Partition * | select `
        Server,`
        @{Name = &#39;Partner&#39;;Expression = {$_.Partner.split(&quot;,&quot;)[1].split(&quot;=&quot;)[1]}},`
        Partition,`
        LastReplicationSuccess,`
        ConsecutiveReplicationFailures,`
        PartnerType,`
        PartnerAddress,`
        PartnerGuid
    
    }
    
    End
    {
       
    }
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/1222909922421349102/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2020/06/get-adreplicationreport-function-to-get.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/1222909922421349102'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/1222909922421349102'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2020/06/get-adreplicationreport-function-to-get.html' title='Powershell : get-ADReplicationReport - Function to get replication status from specified domain controller'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-5600691614286549454</id><published>2019-06-05T12:55:00.002-04:00</published><updated>2020-06-29T17:18:21.058-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Active Directory"/><category scheme="http://www.blogger.com/atom/ns#" term="domain"/><category scheme="http://www.blogger.com/atom/ns#" term="fsmo"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="role"/><category scheme="http://www.blogger.com/atom/ns#" term="script"/><title type='text'>Powershell : Function to get FSMO Info for a domain</title><content type='html'>&lt;pre class=&quot;brush:powershell&quot;&gt;
function Get-DomainFSMO 
{
[CmdletBinding()]
 [OutputType([System.Management.ManagementObject])]
 param
    (
     [parameter( Mandatory=$false,
                    ValueFromPipeline=$True,
                    Position = 0,
                    HelpMessage=&quot;An array of domains.&quot;, 
                 ValueFromPipelineByPropertyName=$True)]
     [String[]] $domain
    )
    begin{Write-Verbose &quot;Getting Forest info for: $CurrentDomain&quot;}
    process{
        foreach ($CurrentDomain in $domain){

          $dom = @{
                                label=&quot;Domain&quot;
                                expression = {$CurrentDomain}
                            }
         
                
         Write-Verbose &quot;Getting Forest info for: $CurrentDomain&quot;
         Get-ADDomain -Server $CurrentDomain | Select-Object $dom,InfrastructureMaster, RIDMaster, PDCEmulator,DomainMode,DomainSid
         
  
    }
    }
    end{}
 
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/5600691614286549454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2019/06/powershell-function-to-get-fsmo-info.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/5600691614286549454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/5600691614286549454'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2019/06/powershell-function-to-get-fsmo-info.html' title='Powershell : Function to get FSMO Info for a domain'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-135886448978261108</id><published>2018-07-27T17:03:00.001-04:00</published><updated>2018-07-27T17:04:07.631-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cpu"/><category scheme="http://www.blogger.com/atom/ns#" term="evc"/><category scheme="http://www.blogger.com/atom/ns#" term="hardware"/><category scheme="http://www.blogger.com/atom/ns#" term="inventory"/><category scheme="http://www.blogger.com/atom/ns#" term="max"/><category scheme="http://www.blogger.com/atom/ns#" term="model"/><category scheme="http://www.blogger.com/atom/ns#" term="number"/><category scheme="http://www.blogger.com/atom/ns#" term="serial"/><category scheme="http://www.blogger.com/atom/ns#" term="VMware"/><title type='text'>vmware - Powershell get hardware inventory</title><content type='html'>Need a script to get serial numbers from my esxi hosts and a few other items 

&lt;pre&gt;
PowerState        : PoweredOn
Version           : 6.0.0
NumCpu            : 12
Cluster           : Clustername
MaxEVCMode        : intel-haswell
vCenter           : vcentername
Name              : esxi host name
Build             : buildnumber
CpuCoreCountTotal : 12
Model             : Hardware model number
MemoryTotalGB     : Total memory of esxi host
CpuModel          : cpu model
MemoryUsageGB     : memory usage at time of report
SerialNumber      : esxi host serial number
ConnectionState   : Connected
&lt;/pre&gt;

Prior to running this make sure you are up to date on your vmware powercli via

&lt;pre class=&quot;brush:powershell&quot;&gt;
Install-Module -Name VMware.PowerCLI
Import-Module VMware.VimAutomation.Core
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -confirm:$false
Update-Module -Name VMware.PowerCLI
&lt;/pre&gt;

&lt;pre class=&quot;brush:powershell&quot;&gt;
$vcenter = &quot;vcenterhostname&quot;

#Tony Unger
#Requires -Version 5

&lt;#If script fails try to run the following commands 

Install-Module -Name VMware.PowerCLI
Import-Module VMware.VimAutomation.Core
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -confirm:$false
Update-Module -Name VMware.PowerCLI

#&gt;

&amp; &#39;C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1&#39;
$report =@()

Connect-VIServer -Server $vcenter


$vmHosts = get-vmhost | select Name,`
ConnectionState,`
PowerState,`
NumCpu,`
MemoryUsageGB,`
MemoryTotalGB,`
Version,`
Build,`
MaxEVCMode,`
@{N=&quot;Cluster&quot;;E={ $_.Parent}},`
@{N=&quot;vCenter&quot;;E={ ($_.uid).split(&quot;@&quot;)[1].split(&quot;:&quot;)[0]}} 

foreach ($vmHost in $vmHosts) {

$VMHardwareInfo = get-vmhosthardware -vmhost $vmHost.name |select Manufacturer,`
Model,`
SerialNumber,`
CpuModel,`
CpuCoreCountTotal

  $ESXiInfo = New-Object -TypeName PSObject -Property @{ 
                        Name = $vmHost.name 
                        ConnectionState = $vmHost.ConnectionState
                        PowerState = $vmHost.PowerState 
                        NumCpu = $vmHost.NumCpu 
                        MemoryUsageGB = $vmHost.MemoryUsageGB             
                        MemoryTotalGB = $vmHost.MemoryTotalGB 
                        Version = $vmHost.Version 
                        Build = $vmHost.Build
                        MaxEVCMode = $vmHost.MaxEVCMode 
                        Cluster = $vmHost.Cluster
                        vCenter = $vmHost.vCenter 
                        Model = $VMHardwareInfo.Model 
                        SerialNumber = $VMHardwareInfo.SerialNumber             
                        CpuModel = $VMHardwareInfo.CpuModel 
                        CpuCoreCountTotal = $VMHardwareInfo.CpuCoreCountTotal 
                       
                    }      
        $report += $ESXiInfo



}


  $report | export-csv -path c:\temp\ESXiHardwareInfo.csv -notype
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/135886448978261108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2018/07/vmware-powershell-get-hardware-inventory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/135886448978261108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/135886448978261108'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2018/07/vmware-powershell-get-hardware-inventory.html' title='vmware - Powershell get hardware inventory'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-2956085502195122690</id><published>2018-04-04T10:26:00.001-04:00</published><updated>2018-04-04T10:26:21.398-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><category scheme="http://www.blogger.com/atom/ns#" term="expires"/><category scheme="http://www.blogger.com/atom/ns#" term="get-msoluser"/><category scheme="http://www.blogger.com/atom/ns#" term="never"/><category scheme="http://www.blogger.com/atom/ns#" term="password"/><category scheme="http://www.blogger.com/atom/ns#" term="passwordneverexpires"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="set-msoluser"/><title type='text'>Azure: powershell one liner to set one user account password to never expire.</title><content type='html'>&lt;pre class=&quot;brush:powershell&quot;&gt;
Install-Module -Name MSOnline
Connect-MsolService
$username = &quot;username&quot;
(get-msoluser -UserPrincipalName&amp;nbsp; $username | select -expand objectID).guid | %{Set-MsolUser -ObjectId $_ -PasswordNeverExpires $true}

&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/2956085502195122690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2018/04/azure-powershell-one-liner-to-set-one.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/2956085502195122690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/2956085502195122690'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2018/04/azure-powershell-one-liner-to-set-one.html' title='Azure: powershell one liner to set one user account password to never expire.'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-5304877428703992519</id><published>2017-09-20T14:55:00.003-04:00</published><updated>2022-01-05T08:36:53.729-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="active"/><category scheme="http://www.blogger.com/atom/ns#" term="adcs"/><category scheme="http://www.blogger.com/atom/ns#" term="cert"/><category scheme="http://www.blogger.com/atom/ns#" term="certificate"/><category scheme="http://www.blogger.com/atom/ns#" term="certutil"/><category scheme="http://www.blogger.com/atom/ns#" term="date"/><category scheme="http://www.blogger.com/atom/ns#" term="days"/><category scheme="http://www.blogger.com/atom/ns#" term="directory"/><category scheme="http://www.blogger.com/atom/ns#" term="expiration"/><category scheme="http://www.blogger.com/atom/ns#" term="expiration date"/><category scheme="http://www.blogger.com/atom/ns#" term="expire"/><category scheme="http://www.blogger.com/atom/ns#" term="parse"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="services"/><category scheme="http://www.blogger.com/atom/ns#" term="wrapper"/><title type='text'>Powershell : Certutil Find Expired Certs on CA server</title><content type='html'>Wrote this to get certificate expiration information for certificates that expired 5 days ago to ones that expire in 90 days. Wrap an invoke-command around this for remote query.

&lt;pre class=&quot;brush:powershell&quot;&gt;
$Before = (get-date).adddays(90).ToString(&quot;MM/dd/yyyy&quot;)
$After = (get-date).AddDays(-5).ToString(&quot;MM/dd/yyyy&quot;)
&lt;#

https://blogs.technet.microsoft.com/poshchap/2016/01/01/powershell-and-certutil-exe/
We create a date range with
$Before, i.e. certificates expiring before this date, and
$After, i.e. certificates expiring after this date. These values are converted into something that certutil can understand - $Restrict. This is then used with the certutil -restrict parameter.
#&gt;
$Restrict = &quot;NotAfter&lt;=$Before,NotAfter&gt;=$After&quot;
$Report = @()
$cmd = &amp; certutil.exe -view -restrict $Restrict -out &quot;RequesterName,CommonName,Certificate Expiration Date&quot;,&quot;Certificate Template&quot;

$SplitLines = $cmd.Split(&quot;`n`r&quot;)

$Index = 0
foreach ($line in $SplitLines){

    if ($line -like &quot;Row*&quot; ){
        $Details = New-Object PSObject 
        $Details | Add-Member noteProperty &quot;RequesterName&quot; $SplitLines[$index+1].split(&quot;:&quot;)[1].Replace(&quot;`&quot;&quot;,&quot;&quot;).Replace(&quot; &quot;,&quot;&quot;)
        $Details | Add-Member noteProperty &quot;CommonName&quot; $SplitLines[$index+2].split(&quot;:&quot;)[1].Replace(&quot;`&quot;&quot;,&quot;&quot;).Replace(&quot; &quot;,&quot;&quot;)
        $Details | Add-Member noteProperty &quot;Certificate Expiration Date&quot; $SplitLines[$index+3].split(&#39;:&#39;)[1].split(&quot; &quot;)[1].Replace(&quot; &quot;,&quot;&quot;)

        
        if ($SplitLines[$index+4].split(&quot;:&quot;)[1].Replace(&quot;`&quot;&quot;,&quot;&quot;) -notlike &quot;*1.*&quot;) {
            $TemplateName = $SplitLines[$index+4].split(&quot;:&quot;)[1].Replace(&quot;`&quot;&quot;,&quot;&quot;).Replace(&quot; &quot;,&quot;&quot;)
        }
        Else {
        write-host &quot;hit&quot;
        $templatename = $SplitLines[$index+4].split(&quot;:&quot;)[1].Replace(&quot;`&quot;&quot;,&quot;&quot;).split(&quot; &quot;)[2].Replace(&quot; &quot;,&quot;&quot;)
        }

        $Details | Add-Member noteProperty &quot;Certificate Template&quot; $TemplateName
        
        
        
        $report += $Details 
    
    }

    $Index++
}
$report
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/5304877428703992519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2017/09/powershell-certutil-find-expired-certs.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/5304877428703992519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/5304877428703992519'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2017/09/powershell-certutil-find-expired-certs.html' title='Powershell : Certutil Find Expired Certs on CA server'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-8054484107465375225</id><published>2017-09-12T13:08:00.001-04:00</published><updated>2017-09-12T13:27:54.139-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="csr"/><category scheme="http://www.blogger.com/atom/ns#" term="generate"/><category scheme="http://www.blogger.com/atom/ns#" term="microsoft"/><category scheme="http://www.blogger.com/atom/ns#" term="new"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="RequestPolicy.inf"/><category scheme="http://www.blogger.com/atom/ns#" term="SAN"/><category scheme="http://www.blogger.com/atom/ns#" term="script"/><title type='text'>Powershell: Generate CSR</title><content type='html'>Wrote this function to generate SAN certificate requests. This isn&#39;t a robust solution, nor does it follow best practice, it is more of a hey it works with a Microsoft CA.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#https://social.technet.microsoft.com/Forums/Lync/en-US/b4e27454-c60f-4346-9f7d-22214f49ab6f/create-inf-file-to-create-req-using-certreqexe?forum=winserversecurity&lt;br /&gt;
&lt;br /&gt;
Found a more correct script after i wrote this here
https://pscsr256.codeplex.com/


&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:powershell&quot;&gt;&amp;lt;#
.Synopsis
   Generate CSR by Tony Unger
.DESCRIPTION
   Generates CSR
.EXAMPLE
   new-csr -CommonName &quot;test0.microsoft.com&quot; -DNSNames $HostNames
.EXAMPLE
   new-csr -CommonName &quot;test0.microsoft.com&quot;
#&amp;gt;
function new-csr
{
    [CmdletBinding()]
    [Alias()]
    [OutputType([int])]
    Param
    (
        # Common name for request
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        $CommonName,

        # SAN DNS names
        [string[]]
        $DNSNames
    )

    Begin
    {
    $Date = (Get-Date).ToString(&#39;ddMMyyyy&#39;)
    $ReqFile = &quot;Cert_Req-$CommonName-&quot; + &quot;$Date&quot; + &quot;.csr&quot;
    }
    Process
    {
        $InfFile = @&quot;
        [NewRequest]`r
        Subject = &quot;CN=$CommonName&quot;`r
        KeySpec = 1
        KeyLength = 2048
        Exportable = TRUE`r
        RequestType = CMC`r
        [Extensions] 
        2.5.29.17 = &quot;{text}&quot; 
        _continue_ = &quot;dns=$CommonName&amp;amp;&quot;`n
&quot;@
    foreach ($DNSName in $DNSNames){
        $InfFile =$InfFile + @&quot; 
            _continue_ = &quot;dns=$DNSName&amp;amp;&quot;`n
&quot;@


    }
    $InfFile
        $FinalInfFile = &quot;Cert_Req_Inf-$CommonName-&quot; + &quot;$Date&quot; + &quot;.inf&quot;
        New-Item $FinalInfFile -type file -value $InfFile -Force

        cmd /c &quot;certreq -new $FinalInfFile $ReqFile&quot;
    }
    End
    {
    }
}

$Hostnames = &quot;test1.microsoft.com&quot;,&quot;test2.microsoft.com&quot;
new-csr -CommonName &quot;test0.microsoft.com&quot; -DNSNames $HostNames

&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/8054484107465375225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2017/09/powershell-generate-csr.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/8054484107465375225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/8054484107465375225'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2017/09/powershell-generate-csr.html' title='Powershell: Generate CSR'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-251290248402668377</id><published>2017-07-06T10:16:00.002-04:00</published><updated>2020-03-25T14:05:37.894-04:00</updated><title type='text'>Set non-domain windows server to use a KMS Server</title><content type='html'>REM List out KMS Servers&lt;br /&gt;
nslookup -type=all _vlmcs._tcp&lt;br /&gt;
&lt;br /&gt;
REM Set workgroup to use a particular KMS Server&lt;br /&gt;
slmgr.vbs /skms &amp;lt;KMS server&amp;gt;:&amp;lt;port&amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/251290248402668377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2017/07/set-non-domain-windows-server-to-use.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/251290248402668377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/251290248402668377'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2017/07/set-non-domain-windows-server-to-use.html' title='Set non-domain windows server to use a KMS Server'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-7269511082450681073</id><published>2017-05-09T15:16:00.001-04:00</published><updated>2017-05-09T15:16:16.888-04:00</updated><title type='text'>Powershell: Get LUN ID with Diskspace</title><content type='html'>get-wmiobject Win32_DiskDrive | select name,caption, scsibus, scsilogicalunit, @{Name=&quot;size(GB)&quot;;Expression={&quot;{0:N1}&quot; -f($_.size/1gb)}} | sort-object name</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/7269511082450681073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2017/05/powershell-get-lun-id-with-diskspace.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/7269511082450681073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/7269511082450681073'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2017/05/powershell-get-lun-id-with-diskspace.html' title='Powershell: Get LUN ID with Diskspace'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-2311539607251014084</id><published>2016-10-18T08:25:00.001-04:00</published><updated>2017-09-12T10:59:07.621-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="active"/><category scheme="http://www.blogger.com/atom/ns#" term="directory"/><category scheme="http://www.blogger.com/atom/ns#" term="get-aduser"/><category scheme="http://www.blogger.com/atom/ns#" term="mass"/><category scheme="http://www.blogger.com/atom/ns#" term="Name"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="principal"/><category scheme="http://www.blogger.com/atom/ns#" term="set-aduser"/><category scheme="http://www.blogger.com/atom/ns#" term="update"/><category scheme="http://www.blogger.com/atom/ns#" term="upn"/><category scheme="http://www.blogger.com/atom/ns#" term="user"/><category scheme="http://www.blogger.com/atom/ns#" term="userprincipalname"/><category scheme="http://www.blogger.com/atom/ns#" term="users"/><title type='text'>Powershell: Change UPN on list of users</title><content type='html'>I needed a script to bulk change a list of users to a new UPN i came up with this.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:powershell&quot;&gt;#
$Users = gc c:\temp\users.txt | get-ADUser

foreach ($User in $Users)
$UserUPN = $User.UserPrincipalname
$UserUPNwithOutDomain = ([regex]::matches($UserUPN, &quot;([^@]+)&quot;)).value[0]
Set-ADUser $User -userprincipalname &quot;$UserUPNwithOutDomain@microsoft.com&quot;
}

&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/2311539607251014084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2016/10/powershell-change-upn-on-list-of-users.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/2311539607251014084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/2311539607251014084'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2016/10/powershell-change-upn-on-list-of-users.html' title='Powershell: Change UPN on list of users'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-3341666413349035319</id><published>2016-05-09T12:08:00.001-04:00</published><updated>2016-05-09T12:31:18.360-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="datastore"/><category scheme="http://www.blogger.com/atom/ns#" term="empty"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="VM"/><category scheme="http://www.blogger.com/atom/ns#" term="VMware"/><title type='text'>Vmware: Powershell List all Datastores and virtual machines within</title><content type='html'>&lt;br /&gt;
Purpose: Need to know if i had any empty datastores attached to my ESXi hosts. Came up with this one liner which will list out all datastores and the vms that are within empty or not.&lt;br /&gt;
&lt;br /&gt;
get-datastore | select name, @{name=&quot;VM&quot;;e={get-datastore $_.name | get-vm } } | fl</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/3341666413349035319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2016/05/vmware-powershell-list-all-datastores.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/3341666413349035319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/3341666413349035319'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2016/05/vmware-powershell-list-all-datastores.html' title='Vmware: Powershell List all Datastores and virtual machines within'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-2274045860368326703</id><published>2016-05-05T09:27:00.003-04:00</published><updated>2016-05-05T09:29:12.635-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="esx"/><category scheme="http://www.blogger.com/atom/ns#" term="esxi"/><category scheme="http://www.blogger.com/atom/ns#" term="host"/><category scheme="http://www.blogger.com/atom/ns#" term="log"/><category scheme="http://www.blogger.com/atom/ns#" term="power"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="shell"/><category scheme="http://www.blogger.com/atom/ns#" term="sys"/><category scheme="http://www.blogger.com/atom/ns#" term="syslog"/><category scheme="http://www.blogger.com/atom/ns#" term="VM"/><title type='text'>VMware: Powershell Query each ESX Hosts Syslog </title><content type='html'>&lt;br /&gt;
This query will report each host and its current Syslog&lt;br /&gt;
&lt;br /&gt;
get-vmhost | select Name,@{Name=&quot;SysLog&quot;; Expression={(get-vmhostsyslogserver $_.name)}} | FL</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/2274045860368326703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2016/05/vmware-powershell-query-each-esx-hosts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/2274045860368326703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/2274045860368326703'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2016/05/vmware-powershell-query-each-esx-hosts.html' title='VMware: Powershell Query each ESX Hosts Syslog '/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-7677069217350367008</id><published>2016-04-18T10:15:00.002-04:00</published><updated>2016-04-18T10:17:20.447-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="account"/><category scheme="http://www.blogger.com/atom/ns#" term="accounts"/><category scheme="http://www.blogger.com/atom/ns#" term="ad"/><category scheme="http://www.blogger.com/atom/ns#" term="all"/><category scheme="http://www.blogger.com/atom/ns#" term="domain"/><category scheme="http://www.blogger.com/atom/ns#" term="job"/><category scheme="http://www.blogger.com/atom/ns#" term="service"/><category scheme="http://www.blogger.com/atom/ns#" term="services.msc"/><category scheme="http://www.blogger.com/atom/ns#" term="user"/><category scheme="http://www.blogger.com/atom/ns#" term="windows"/><title type='text'>Powershell: Get services and accounts used to run them on all computers using Jobs</title><content type='html'>&lt;!--SYNTAX HIGHLIGHTER BEGINS--&gt;&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushpowershell.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot;&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = &#39;http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf&#39;;
SyntaxHighlighter.all();
&lt;/script&gt;&lt;!--SYNTAX HIGHLIGHTER ENDS--&gt;

&lt;pre class=&quot;brush:powershell&quot;&gt;

cls
####################
#By Tony Unger
#Purpose: inventory all services and user accounts running them with jobs
#
##
$myCol = @()
$i =0  
$servers = get-adcomputer -filter * | select -expand name 

$scriptblock = {
 param([string]$server)

get-wmiobject win32_service -computername $Server | select *

}

$ServersCount = $Servers.count

foreach($server in $Servers){
    $i++
    $running = @(Get-Job | Where-Object { $_.State -eq &#39;Running&#39; })
 Write-Progress -Activity &quot;Gathering computer info&quot; -status &quot;Currently on $server -- $i of $ServersCount&quot; -percentComplete ($i / $ServersCount*100)
 if ($running.Count -le 50) {
        Start-Job -ScriptBlock $scriptblock -Name $server -ArgumentList $server, $creds 
    } 
 else {
         $running | Wait-Job
    }
}

while ($running.Count -ge 1) {
      sleep 1 
    $running = @(Get-Job | Where-Object { $_.State -eq &#39;Running&#39; })
} 


foreach ($job in Get-Job ){

 $recjobs = Receive-Job -Keep -Job $job 
 foreach ($recjob in $recjobs){
    $Detail = New-Object PSObject 
     
  $Detail | Add-Member Noteproperty Caption $recjob.Caption
  $Detail | Add-Member Noteproperty Name $recjob.name 
  $Detail | Add-Member Noteproperty Startname $recjob.startname
        $Detail | Add-Member Noteproperty Server $recjob.__SERVER
  $myCol += $Detail

 }
}

&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/7677069217350367008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2016/04/powershell-get-services-and-accounts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/7677069217350367008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/7677069217350367008'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2016/04/powershell-get-services-and-accounts.html' title='Powershell: Get services and accounts used to run them on all computers using Jobs'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-368776682587769985</id><published>2016-02-03T09:39:00.002-05:00</published><updated>2016-03-01T20:29:18.924-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="active"/><category scheme="http://www.blogger.com/atom/ns#" term="all"/><category scheme="http://www.blogger.com/atom/ns#" term="directory"/><category scheme="http://www.blogger.com/atom/ns#" term="job"/><category scheme="http://www.blogger.com/atom/ns#" term="jobs"/><category scheme="http://www.blogger.com/atom/ns#" term="log"/><category scheme="http://www.blogger.com/atom/ns#" term="off"/><category scheme="http://www.blogger.com/atom/ns#" term="powershell"/><category scheme="http://www.blogger.com/atom/ns#" term="rdp"/><category scheme="http://www.blogger.com/atom/ns#" term="servers"/><category scheme="http://www.blogger.com/atom/ns#" term="shell"/><category scheme="http://www.blogger.com/atom/ns#" term="user"/><category scheme="http://www.blogger.com/atom/ns#" term="users"/><title type='text'>Powershell: RDP log user account off of all servers using jobs.</title><content type='html'>&lt;!--SYNTAX HIGHLIGHTER BEGINS--&gt;&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushpowershell.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot;&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = &#39;http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf&#39;;
SyntaxHighlighter.all();
&lt;/script&gt;&lt;!--SYNTAX HIGHLIGHTER ENDS--&gt;

&lt;pre class=&quot;brush:powershell&quot;&gt;
#Log User account off all servers
# Tony Unger
# 

$Domain = &quot;Microsoft.com&quot;
$Servers = Get-ADComputer -Filter {(OperatingSystem -Like &quot;Windows Server*&quot;)-and (enabled -eq &quot;true&quot;)} -Property SamAccountName -Server $Domain Select -expand Name
$username = read-host &quot;Enter Users Name:&quot;
$i = 0

$scriptblock = {
 param(
 [string]$server,
 $Username
 )

$queryResults = (qwinsta /server:$server $Username| foreach { (($_.trim() -replace &quot;\s+&quot;,&quot;,&quot;))} | ConvertFrom-Csv)
 foreach ($queryResult in $queryResults){
  Logoff /server:$server $queryResult.id
 }
}
$TotalServersCount = $Servers.count
foreach($server in $Servers){
$i++
    $running = @(Get-Job | Where-Object { $_.State -eq &#39;Running&#39; })
 Write-Progress -Activity &quot;logging off user&quot; -status &quot;Currently on $server -- $i of $TotalServersCount&quot; -percentComplete ($i / $Servers.count*100)
 if ($running.Count -le 50) {
        Start-Job -ScriptBlock $scriptblock -Name $server -ArgumentList $server, $username
    }
 else {
         $running | Wait-Job
    }
}

while ($running.Count -ge 1) {
      sleep 1
    $running = @(Get-Job | Where-Object { $_.State -eq &#39;Running&#39; })
 Remove-Job -State Completed
}

&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/368776682587769985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2016/02/powershell-rdp-log-of-user-account-off.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/368776682587769985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/368776682587769985'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2016/02/powershell-rdp-log-of-user-account-off.html' title='Powershell: RDP log user account off of all servers using jobs.'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8463146875506159962.post-5523547247157956989</id><published>2015-12-24T10:04:00.002-05:00</published><updated>2015-12-24T10:10:28.592-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cluster"/><category scheme="http://www.blogger.com/atom/ns#" term="liner"/><category scheme="http://www.blogger.com/atom/ns#" term="on"/><category scheme="http://www.blogger.com/atom/ns#" term="one"/><category scheme="http://www.blogger.com/atom/ns#" term="powered"/><category scheme="http://www.blogger.com/atom/ns#" term="total"/><category scheme="http://www.blogger.com/atom/ns#" term="VM"/><category scheme="http://www.blogger.com/atom/ns#" term="VMware"/><title type='text'>Powershell: VMware one liner to list total vm that are powered on each host</title><content type='html'>This one liner will query each host and id its cluster total vms and how many VMs are powered on&lt;!--SYNTAX HIGHLIGHTER BEGINS--&gt;&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushpowershell.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot;&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = &#39;http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf&#39;;
SyntaxHighlighter.all();
&lt;/script&gt;&lt;!--SYNTAX HIGHLIGHTER ENDS--&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:powershell&quot;&gt;Get-VMHost | Select @{N=&quot;Cluster&quot;;E={Get-Cluster -VMHost $_}}, Name, @{N=&quot;Total_VMs&quot;;E={($_ | Get-VM).Count}},@{N=&quot;Powered_On&quot;;E={($_ | get-vm | ? {$_.powerstate -like &quot;*ON*&quot;}).count}} | Sort Cluster, Name | fl
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.tonyunger.com/feeds/5523547247157956989/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.tonyunger.com/2015/12/powershell-vmware-one-liner-to-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/5523547247157956989'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8463146875506159962/posts/default/5523547247157956989'/><link rel='alternate' type='text/html' href='http://www.tonyunger.com/2015/12/powershell-vmware-one-liner-to-list.html' title='Powershell: VMware one liner to list total vm that are powered on each host'/><author><name>tony</name><uri>http://www.blogger.com/profile/10869470800445971209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>