TechShizz | All posts tagged 'CMD'

Take Ownership

Take ownership of folder + delete - Run all three commands


takeown /F D:\My Documents\OneNote Notebooks* /R /A

cacls D:\My Documents\OneNote Notebooks*.* /T /grant administrators:F

rmdir /S /Q D:\My Documents\OneNote Notebooks

Active Directory Replication Commands


Repadmin /replsummary

Identifies domain controllers that are failing inbound replication or outbound replication, and summarizes the results in a report.


Repadmin /Queue

Displays inbound replication requests that the domain controller has to issue to become consistent with its source replication partners.


Repadmin /Showrep

Displays the replication status when the specified domain controller last attempted to perform inbound replication of Active Directory partitions

Find Asset Tag / Serial Number

wmic bios get serialnumber

 

To get the product number I think its:

 

Get-WmiObject win32_computersystem | Select-Object SystemSKUNumber

Windows Update Fix

If windows update fails to install try this:
Step by step instructions to get the issue fixed.

 

a) Press Windows key + X and select Command Prompt (Admin).

  

b) On the open Command Prompt window copy and paste the commands (all at once)

 

net stop wuauserv

 

net stop cryptSvc

 

net stop bits

 

net stop msiserver

 

ren C:\Windows\SoftwareDistribution SoftwareDistribution.old

 

ren C:\Windows\System32\catroot2 catroot2.old

 

net start wuauserv

 

net start cryptSvc

 

net start bits

 

net start msiserver

 

c) Wait for the process to complete.

 

d) Close the Command Prompt.

 

 

Now, try to install Windows Updates again and check if it helps.

 

=======================================================

 

I was getting this error too, but solved removing a value from registry:

  • Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsSelfHost\Applicability
    • ThresholdOptedIn

How is my registry now (downloading updates):


Shadow Groups

DS-Tools

The Quick and Dirty version:
dsquery user “<Organizational Unit distinguishedName>” –scope onelevel | dsmod group “<Shadow Group distinguishedName>” –chmbr

This will look for all users found in the specified OU, and limit the search to that OU only. Then it will clear the current group membership of the SG and add all users currently found in the OU.

The Clean and Clever batch file version:
Set OU=Organizational Unit distinguishedName (without quotes)
Set Group=Shadow Group distinguishedName (without quotes)

dsget group %Group% –members | find /v /i “%OU%” | dsmod group “%Group%” –rmmbr
dsquery * “%OU%” –filter “(&(sAMAccountType=805306368)(!memberOf=%Group%))” –scope onelevel | dsmod “%Group%” –addmbr


This will look at the group membership, pipe it to the find command, to find only the users where the OU’s distinguishedName is NOT present, and then pipe it to dsmod group to remove those users from the group. The next step is to look for all users in the specified OU that are NOT member of the Shadow Group already. It will then add any users found to the group.

PowerShell

Windows Server 2008 R2 with Active Directory cmdlets:
$OU=”Organizational Unit distinguishedName”
$Group=”Shadow Group distinguishedName”

Get-ADGroupMember –Identity $Group | Where-Object {$_.distinguishedName –NotMatch $OU} | ForEach-Object {Remove-ADPrincipalGroupMembership –Identity $_ –MemberOf $Group –Confirm:$false}
Get-ADUser –SearchBase $OU –SearchScope OneLevel –LDAPFilter “(!memberOf=$Group)” | ForEach-Object {Add-ADPrincipalGroupMembership –Identity $_ –MemberOf $Group}
 

This will do the same thing as the ds-tools clean and clever version, except it’s done in PowerShell with the AD cmdlets.

Once you’ve decided for what approach you want to take, you can easily create a scheduled task for this and ensure that the batch or PowerShell script runs at intervals that suits your organization. Just make sure that the user account the scheduled task runs under has got the proper privileges (such as log on as batch job and permission to update the Shadow Groups (write members) in Active Directory).