Rexxer

Some tips for me and other

Powershell + string to array

An array is created with the -split operator. Like so, $myString=”Four score and seven years ago” $arr = $myString -split ‘ ‘ $arr # Print output Four score and seven years ago When you need a certain item, use array index to reach it. Mind that index starts from zero. Like so, $arr[2] # 3rd […]

Group policy + Account lockout audit

Found out the strange thing: my script for locked out accounts stopped working after 21 November 2018. I checked eventlog and didn’t see any 4740 events. After investigation I resolved it. It must be turned on there: Computer configuration/Policies/Windows Settings/Security settings/Advanced Audit Policy Configuration/Logon/Logoff/Audit Account Lockout Then I checked it: Auditpol /get /category:*

MDT + Script for joining to a domain

$strUser = “domain\user” $strDomain = “domain.local” $strPassword = ConvertTo-SecureString “password” -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PsCredential $strUser, $strPassword $strOU = “OU=Computers,DC=domainn,DC=local” Add-computer -DomainName $strDomain -Credential $Credentials -OUPath $strOU

MDT + Script for renaming a PC according to his IP

powershell.exe -noprofile -command “Set-ExecutionPolicy Bypass LocalMachine” -force $strPrefix=”WS” # Get IP and make the name $IP=(Get-WmiObject win32_networkadapterconfiguration | Select-Object -Property @{name=’IPAddress’;Expression={($_.IPAddress[0])}} | Where IPAddress -NE $null).IPAddress $a,$b,$c,$d = $IP.split(‘.’) $strComputerName=$strPrefix+$c+”-“+$d # Rename $computer=gwmi Win32_computersystem $computer.rename($strComputerName)

Get test before dot

s=”4.56″ $ echo “${s%%.*}” 4

Exchange 2010 + Re-index DB

Issue: Users can’t find some e-mails with searching The Internet suggest several ways to resolve the issue like: Update-MailboxDatabaseCopy –Identity ‘DB2’ –CatalogOnly or 1. stop the Exchange Search Indexer and Search service 2. go to the location of the mailbox database. 3. there should be a folder called catalog{GUID}. Delete the folder 4. Restart the […]

Exchange 2010 + Powershell + Search and delete specific mail

Task: Find and delete all the e-mail that contains specific attachment. 1. Estimate and debug our query: Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery ‘attachment:”My file example*”‘ -TargetMailbox “my.mailbox” -TargetFolder “MyFolder” -Logonly -Loglevel Full | Select DisplayName, ResultItemsCount | where-object {$_.ResultItemsCount -ne “0”} and check the folder for the report or Get-Mailbox -ResultSize Unlimited | Search-Mailbox […]

Unable to do anything with usb-flash after disk imaging

I often do bootable usb-flash-disks with Win32image software. But when you decide to format it with Windows disk management you can face an issue – it can’t be done. All the options are grey out. You can fix it with diskpart – just select this disk and delete all the partitions on it and you […]

PFSense upgrade

Usually upgrade passes without issues but it can be painfull sometimes. I did upgrade from version 2.2.x to 2.4.3 and got a lot of errors about PHP and other modules especially “Tftp-server”. I tried to reboot the server and it was lost. So I went to the place and tried to do something but without […]

Fix All Failed Exchange Database Content Indexes

Source:https://practical365.com/exchange-server/fix-all-failed-exchange-database-content-indexes/ One of the issues that my Get-DAGHealth.ps1 script alerts for is failed content indexes on database copies in a database availability group. Note: for failed content indexes on servers that are not DAG members refer to this article instead. Failed content indexes can easily go unnoticed when everything else is working fine however they […]

Previous Posts