Stuff I Forgot

 

Task to free up IP on DHCP until later

October 24, 2017 / Leave a comment

$server = “dhcpserver.domain.local”
# scope on dhcp server

$scopeid= “10.10.10.0”

 

#Get-DhcpServerv4Scope -ComputerName $server

$Before = Get-DhcpServerv4ScopeStatistics -ComputerName $server -ScopeId $scopeid

 

$iplist = Get-DhcpServerv4Lease -ComputerName $server -ScopeId $scopeid

foreach ($ip in $iplist)
{
#$ip.IPAddress.IpAddressToString
#$ip.Hostname

If ($ip.Hostname -like ‘*iphone*’ -or $ip.Hostname -like ‘*android*’)

{write-host $ip.hostname ” ” $ip.IPAddress.IpAddressToString

remove-dhcpserverv4lease -ComputerName $server -IPAddress $ip.IPAddress.IpAddressToString
}

}
$After=Get-DhcpServerv4ScopeStatistics -ComputerName $server -ScopeId $scopeid

Write-Host “——————Summary —————–”

Get-Date -Format g | out-file -append C:\Scripts\Powershell\freeupip\log.txt
$Before.Free | out-file -append C:\Scripts\Powershell\freeupip\log.txt
$After.Free | out-file -append C:\Scripts\Powershell\freeupip\log.txt

 

Purge Items found in O365 Content Search

July 8, 2017 / Leave a comment

#You must do content search first
$contentname = “Name you created for search” #name of content search and results

# Get login credentials
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber -DisableNameChecking
$Host.UI.RawUI.WindowTitle = $UserCredential.UserName + ” (Office 365 Security & Compliance Center)”

New-ComplianceSearchAction -SearchName $contentname -Purge -PurgeType SoftDelete

#This is handy for when you get those emails users cant resist clicking.

Create Content Search in O365

July 8, 2017 / Leave a comment

#https://technet.microsoft.com/library/mt210905(v=exchg.160).aspx

#You must create named content search first
$contentname = “Test Search with anyname” # name of content search
$contentsearch = “www.loctite2017.com” # what you are searching for
$context = “youremail@email.com” # or replace with ALL for all mailboxes

 

# Get login credentials
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber -DisableNameChecking
$Host.UI.RawUI.WindowTitle = $UserCredential.UserName + ” (Office 365 Security & Compliance Center)”

New-ComplianceSearch -Name $contentname -ContentMatchQuery $contentsearch -ExchangeLocation $context -AllowNotFoundExchangeLocationsEnabled $true
#starts takes a sec..
Start-ComplianceSearch -Identity $contentname

Block IP in O365

April 11, 2017 / Leave a comment

Import-Module MSOnline
$cred = Get-Credential
#Connect-MsolService -Credential $cred

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Cred -Authentication Basic –AllowRedirection
Import-PSSession $Session -AllowClobber
#Set-OrganizationConfig -IPListBlocked @{add=”xx.xx.xx.xx”}
#Set-OrganizationConfig -IPListBlocked @{remove=”xx.xx.xx.x”}
#Get-OrganizationConfig | select IPListBlocked
Remove-PSSession $Session

o365 Stuff – Disable Sway and TEAM1

February 1, 2017 / Leave a comment

#Login to O365

$UserCred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri

https://outlook.office365.com/powershell-liveid/ -Credential $UserCred -Authentication Basic -AllowRedirection

Import-PSSession $Session

Import-Module MSOnline
Connect-MsolService

#get sku info

Get-MsolAccountSku | Format-List –property accountskuid,activeunits,consumedunits

#get Services plan info

Get-MsolAccountSku | Where-Object {$_.SkuPartNumber -eq “ENTERPRISEPACK_FACULTY”} | ForEach-Object {$_.ServiceStatus}

#meat of it

$x = New-MsolLicenseOptions -AccountSkuId “yourinfo365:ENTERPRISEPACK” -DisabledPlans “SWAY”,”TEAM1″

#also could have done ENTERPRISEWITHSCAL or whatever

#one user

Set-MsolUserLicense -UserPrincipalName user@mydomain.com -LicenseOptions $x

#allusers

Get-MsolUser -all | Where-Object {$_.isLicensed -eq $True} | Set-MsolUserLicense -LicenseOptions $x