Took longer then expected to work this out, here it is Get-ADUser -filter * -properties * | Where-Object {$_.Enabled -eq $true} |where-object {$_.Passw ordExpired -eq $true} |select name,passwordexpired,mail You can see where there are 2 properties being checked, and I think is should be easy to add a third. wonder if there is a cleaner […]
Category: Powershell
Restart a Service Remotely with Powershell
I have found lots of fancy ways, but here is my one(two) liner (get-service -ComputerName server01 -Name wuauserv).stop (get-service -ComputerName server01 -Name wuauserv).start
Force Delete a File
WARNING!!! THIS WILL FORCE DELETE FILES, USE AT YOUR OWN RISK!!! This one has hounded me many times, and I thought I already did a KB for this, but apparently not, so here goes; First make sure everyone is off, I use the MS file sharing MSC, “Share and Storage Management”. On the […]
SharePoint Online Time Out
Just a quick on this. a great link is here; https://techcommunity.microsoft.com/t5/Microsoft-SharePoint-Blog/Idle-Session-Timeout-Policy-in-SharePoint-Online-amp-OneDrive-is/ba-p/211274 PS C:\Windows\system32> Connect-SPOService -Url https://<tenent>-admin.sharepoint.com PS C:\Windows\system32> get-SPOBrowserIdleSignOut Enabled WarnAfter SignOutAfter ——- ——— ———— True 00:05:00 00:30:00 PS C:\Windows\system32> Set-SPOBrowserIdleSignOut -Enabled $true -WarnAfter (New-TimeSpan -Seconds 2700) -SignOutAfter ( New-TimeSpan -Seconds 3600)
Add Images to Word from Command (Powershell)
Really all the credit has to go to u/Pandapokeman on reddit. All I did was add a single line that added the file name to the bottom of the picture. https://www.reddit.com/user/Pandapokeman/ Here is his script (be sure to use the full file path in the command) Function Add-OSCPicture { <# .SYNOPSIS Add-OSCPicture is an advanced […]
New Powershell command Get-PerimeterMessageTrace
So I want to put this out there, because I googled the crap out to this hand got zero information. When doing an exchange message trace, it was used to see incoming email. going to have to explore this more, and find out what it really can do. PS C:\Windows\system32> PS C:\Windows\system32> Get-PerimeterMessageTrace […]
Windows Commands PDF
Not all of them (nslookup) but damn near all of them
Exchange Powershell Context
I had a frustrating problem, where powershell was not returning the correct results that I was expecting, it was missing a 95% of the data from a simple get-mailbox command. It turns out, that running exchange powershell commands from the “Exchange Management Shell” sets the environment to the local server, even if you use the […]
Show all Domain Computers that are Online
Quickie one liner; get-adcomputer -filter * | Where { Test-Connection $_.name -count 1 -quiet } | Select @{Name=”Computername”;Expression={$_.Name}} Reference : https://www.petri.com/test-network-connectivity-powershell-test-connection-cmdlet
Find all RDP (and Console) Sessions in the Domain
Quickie one liner $work = Get-ADComputer -filter * $work = $work.name foreach ($1 in $work){write-host $1 ; quser /server:$1} This also works (courtesy of jrv [technet]); Get-ADComputer -Filter *| ForEach-Object{ quser /server $_.Name} Or to get a single computer Get-ADComputer <servername> | ForEach-Object{ quser /server $_.Name}