My Blog List

Wednesday, July 20, 2022

Daily commands

 

1. #Check installed windows updates:  

wmic qfe

2. PS H:\> Get-FileHash C:\Excel\NSClient.msi -Algorithm MD5          


3. #get installed software on a machine(cmd)

Wmic product get name, version, vendor

4. # remote connect to a PC via Powershell 

Enter-PSSession -ComputerName BA-L156YBD

5. #remote cmd

psexec \\RemoteComputer cmd.exe

6. #uninstall GPL Ghost script

"%ProgramFiles%\gs\gs9.27\uninstgs.exe" /S

7. #install CW over cmd remote

msiexec.exe /i "c:\intel\Agent_Install.MSI" ALLUSERS=1 /qn /norestart /log output.log

8. #get running services

Net start

9. #Enable Remote Desktop connections

Set-ItemProperty ‘HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\‘ -Name “fDenyTSConnections” -Value 0

10. #Enable Network Level Authentication

Set-ItemProperty ‘HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\‘ -Name “UserAuthentication” -Value 1

11. #Enable Windows firewall rules to allow incoming RDP

Enable-NetFirewallRule -DisplayGroup “Remote Desktop”

12. #enable Win10 firewall for RDP remotely

psexec.exe \\<computer name> netsh firewall set service RemoteDesktop enable

13. #Find active sessions citrix

query user

Logoff ID

14. #check windows update cmd

wuauclt.exe /updatenow

15. #get last login date 

Get-ADComputer -Identity BA-CAN-TELLER02 -Properties LastLogonDate  


Get-ADComputer -filter {operatingsystem -like "Windows 10*"  } -Properties OperatingSystemVersion, lastlogondate|select name,OperatingSystemVersion,LastLogonDate

16. #Registry Lookup

Some swear by looking things up in the registry. Not my recommended approach - I like going through proper APIs (or in other words: OS function calls). There are always weird exceptions accounted for only by the internals of the API-implementation:

• HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

• HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall

• HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall


17. #NS uninstall

c:\Intel>msiexec /x "NSClient v83.0.0.538.msi" /quiet /norestart


18. #NS Uninstall String

MsiExec.exe /I{FA933B0A-816B-4001-915F-8F2625B8E1A8}


19. #create firewall rule to enable default sql services

New-NetFirewallRule -DisplayName "SQLServer default instance" -Direction Inbound -LocalPort 1433 -Protocol TCP -Action Allow

New-NetFirewallRule -DisplayName "SQLServer Browser service" -Direction Inbound -LocalPort 1434 -Protocol UDP -Action Allow


20. #install .msp file 

msiexec /p C:\Windows\LTSvc\packages\lync2016-kb4475545x86\lync-x-none.msp REINSTALL=ALL REINSTALLMODE=omus /qn


https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec


21. #messageLabs

top left > Address Registration > choose domain bankaust.com.au > add New Address


22. #Change UPN

Set-ADUser -UserPrincipalName test01@test.local -Identity it.servicedeskdev

23. #uninstall Silverlight 

wmic product where caption='Microsoft Silverlight' call uninstall


24. #Robocopy 

Robocopy "\\ba-pqhyp01\d$\Shared" "C:\Hype" /copyall /s /zb /tee 


25. #Get AD users filtered by name

get-aduser -Filter 'Name -like "*sql*"' | select name, samaccountname


26. #Get AD permissions on an OU

(Get-ACL "AD:$((Get-ADOrganizationalUnit -Identity 'OU=HR,DC=SHELLPRO,DC=LOCAL').distinguishedname)").access | Select IdentityReference,AccessControlType

#array

$array = Import-Csv -Path C:\AH\AD\Empty_pass_usernames.csv

foreach($name in $array){

  Get-ADUser -Identity $name.username -Properties useraccountcontrol | Select Samaccountname, useraccountcontrol, Enabled } 

27. #change useraccountcontrol value to 512

$array = Import-Csv -Path C:\AH\AD\Empty-pass-turn512.csv

foreach($name in $array){

  Set-ADUser -Identity $name.username -Replace @{useraccountcontrol=512}

}







Steps to extract ntfs share details from file server shares

As part of a file server consolidation effort, I was tasked to come up with a method to move multiple shares on multiple shares to a WSFC. I...