Wednesday, December 6, 2017

Clear IIS logs using powershell script

get-childitem -Path c:\inetpub\logs\logfiles\w3svc*\*.log -recurse |
where-object {$_.lastwritetime -lt (get-date).addDays(-30)} |
Foreach-Object { del $_.FullName }

Tuesday, November 28, 2017

“The RPC server is unavailable” while trying to take Remote Desktop of 2003 Server

When trying to logon to Windows server 2003 via remote desktop you receive the following message:

The system cannot log you on due to the following error:
The RPC server is unavailable.
Please try again or consult your system administrator.

You will also receive the following event in the target server’s application event log:

Event ID: 1219
Logon rejected for Domain\User. Unable to obtain Terminal Server User Configuration. Error: The RPC server is unavailable.

To resolve this :

1. Locate the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
2. Create a new DWORD called IgnoreRegUserConfigErrors
3. Give it a value of 1

Source

Friday, November 10, 2017

ADD extensionAttribute

If you have different upn names , than your domain server name and you need to use different upn-s for ldap queris you can add sammaacountname + server domain name to custem attributes.

In file atribute.txt write users sammaccountnames.

Import-Module ActiveDirectory
$Users = Get-Content c:\tmp\atribute.txt
ForEach ($User in $Users) {
$username = Get-ADUser -Server test.local -Identity "$user" -Properties  samaccountname |select -ExpandProperty samaccountname
Set-ADUser -Server test.local -Identity "$user" -Add @{extensionAttribute13="$Username@test.local"}
}

Wednesday, September 13, 2017

Port forwarding on WIndows Server

run cmd as Administrator

netsh interface portproxy add v4tov4 listenaddress=YOUR_IP_HERE listenport=8080 connectaddress=YOUR_IP_HERE connectport=80

to view proxy rules use this command:

netsh interface portproxy show all


tocheck use this command:

netstat -ano | findstr :<listenport number>

To delete this rule use command:

netsh interface portproxy delete v4tov4 listenaddress=YOUR_IP_HERE listenport=8080 connectaddress=YOUR_IP_HERE connectport=80





Wednesday, September 6, 2017

Exchange 2010: can’t remove move request – Failed to communicate with the mailbox database

After a failed move request, the mailbox is still marked is being moved and cannot be removed again

After a failed move request, sometimes (for unknown reason) the mailbox is still marked is being moved and cannot be removed again... the mailbox is shown with a green icon on the EMC (Exchange Management Console), however it cannot be seen on the "Move Request" section or with Get-MoveRequest command and cannot be cleared with the Remove-MoveRequest command.


1. Open User Attributes
2. Scroll down the attributes and search for an entry called "msExchMailboxMoveTargetMDBLink" and "msExchMailboxMoveBatchName".
5. Click on the "Edit" button.
6. Click on the "Clear" button.
7. Click the "OK" button.

If you have many users you can use powershell script:


$Users = Get-Content c:\tmp\atribute.txt

ForEach ($User in $Users) {

Set-ADUser -Server test.local -Identity "$user" -Clear "msExchMailboxMoveTargetMDBLink"
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$Users = Get-Content c:\tmp\atribute.txt

ForEach ($User in $Users) {

Set-ADUser -Server test.local -Identity "$user" -Clear "msExchMailboxMoveBatchName"
}
in c:\tmp\atribute.txt put user DN-s.

After this you can remove failed moves from exchange console.

Friday, September 1, 2017

Troubleshooting KMS Server

run from CMD: nslookup -type=srv _vlmcs._tcp


Check if the server is up and running.
Check if the “Software Protection” service (sppsvc) is running.
Verify if the KMS service is listening on port 1688: telnet localhost 1688
Verify the KMS status. Run from CMD: slmgr.vbs /dli
Verify if a KMS key is installed and activated.
Verify if the minimum threshold for activation is being met.
Verify if other clients are able to activate using KMS. Even though the output of “slmgr.vbs /dli” gives you an indication, you can use the “Volume Activation Management Tool” (VAMT) for more insight and functionality.
Verify that a VLK key is being used.

Set the MaxPageSize in Active Directory

In large environments there are lots of objects in Active Directory. Querying the objects via LDAP is done by different third party applications to (for example) verify users. But sometimes these queries return an error with regard to the sizelimit and not all objects are returned.
 You can change this limit with the ADSI Edit Snap-in. 

CN=Default Query Policy, CN=Query-Policies, CN=Directory Service, CN=Windows NT, CN=Services, CN=Configuration, DC=YOUR_COMPANY, DC=YOUR_COMPANY_TLD

Doubleclick on the lDapAdminLimits. Click on MaxPageSize and remove the entry. Change the entry as shown next :
MaxPageSize=10000