Showing posts with label CMD. Show all posts
Showing posts with label CMD. Show all posts

Friday, November 16, 2018

Logon script to restart computers from list

for /F "tokens=*" %%x in ('type c:\tmp\restart.txt') do ( shutdown.exe -m "%%x" -t 0 -r -f )
pause


in txt file write computer fqdn names 

Change Mozilla Firefox home page GPO


On old versions  Mozilla ADMX does not work properly
to change home page use this bat script (create log on script policy)

---------------

echo off
cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
cd *.default
set ffile=%cd%
echo %user_pref("browser.startup.homepage", );% del /f /q "%ffile%\prefs.js"
echo user_pref("browser.startup.homepage", "http://int.psh.gov.ge");>>"%ffile%\prefs.js"
set ffile=
cd %windir%

------------------


If your mozilla version is higher, than 60 version, you can you ADMX templates (Create computer base policy)

you can download here :

https://github.com/mozilla/policy-templates/releases



Monday, February 12, 2018

Enabling Disk Performance Counters in Windows Server 2012 R2 Task Manager

  1. Ensure Task Manager is closed.
  2. Launch the Command Prompt using the "Run as Administrator" option. 
  3. Enter the following at the Command Prompt:  diskperf -Y

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





Thursday, August 31, 2017

Install a Windows service using a Windows command prompt

run CMD as Administrator:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\myservice.exe"

Tuesday, May 23, 2017

DiskPart to extend a volume from CMD

1: Go to Start, Run, then type

cmd

2:Type
diskpart

3: Type
list volume
to list the current volumes. The list will look like

  Volume ### Ltr Label Fs Type       Size  Status   Info
   ---------- --- ------------------- ----- -------- -------
   Volume 0   C   NTFS Partition      10 GB Healthy  System
   Volume 1   D   Data NTFS Partition  9 GB Healthy  Pagefile

4 Type
select volume <volume number>

to select the volume you want to extend.
5 Type
extend

to extend the selected volume. If you don't pass any parameters, DiskPart will use all unpartitioned space on the current disk. Alternatively, you can type

extent size=<size in MB> disk=<disk number>

to set a size and disk to use for the extension.
6 type
exit

Monday, April 10, 2017

Logon Script to delete all browser cashe

@echo off

REM Cookies:

REM RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

REM RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

::Firefox

@echo off

taskkill /im "firefox.exe"

set DataDir=C:\Users\%USERNAME%\AppData\Local\Mozilla\Firefox\Profiles

del /q /s /f "%DataDir%"

rd /s /q "%DataDir%"

for /d %%x in (C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite

::Google Chrome

@echo off

ECHO **** Clearing Chrome cache
taskkill /F /IM "chrome.exe">nul 2>&1

set ChromeDataDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default
set ChromeCache=%ChromeDataDir%\Cache>nul 2>&1  
del /q /s /f "%ChromeCache%\*.*">nul 2>&1    
del /q /f "%ChromeDataDir%\*Cookies*.*">nul 2>&1    
del /q /f "%ChromeDataDir%\*History*.*">nul 2>&1    


set ChromeDataDir=C:\Users\%USERNAME%\Local Settings\Application Data\Google\Chrome\User Data\Default
set ChromeCache=%ChromeDataDir%\Cache>nul 2>&1
del /q /s /f "%ChromeCache%\*.*">nul 2>&1   
del /q /f "%ChromeDataDir%\*Cookies*.*">nul 2>&1    
del /q /f "%ChromeDataDir%\*History*.*">nul 2>&1    
ECHO **** Clearing Chrome cache DONE


::Internet Explorer
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

:Clear temp files
erase "%TEMP%\*.*" /f /s /q
for /D %%i in ("%TEMP%\*") do RD /S /Q "%%i"

erase "%TMP%\*.*" /f /s /q
for /D %%i in ("%TMP%\*") do RD /S /Q "%%i"

Thursday, March 30, 2017

Restore 127.0.0.1 routes Windows

After commad route -f all routes will be removed.

To restore loopback adapter rotes use this commands :

route add  127.0.0.0 mask 255.0.0.0  0.0.0.0 metric 306 if 1
route add  127.0.0.1 mask 255.255.255.255  0.0.0.0 metric 306 if 1
route add  255.255.255.255 mask 255.255.255.255  0.0.0.0 metric 306 if 1

Monday, February 27, 2017

View Disk size and free space from CMD

wmic logicaldisk get size,freespace,caption

Wednesday, February 15, 2017

Stop a hung service

If service is hung on stoping or starting :

open CMD as administrator

sc queryex "servicename"
taskkill /f /pid [PID] 




Source


Thursday, February 9, 2017

View logged on user on Remote computer

View logged on user on Remote computer.

Download PStools. Use PSexec utill. I have pstools on my C drive.

cd c:\
cd pstolls
psexec.exe \\"compname or ip" cmd.exe
query user

Tuesday, January 24, 2017

Send Mail from CMD

telnet localhost smtp
HELO yahoo.com
mail from: sender@test.com
250 2.1.0 sender@tecadmin.net... Sender ok
rcpt to: myemail@mail.com
250 2.1.5 myemail@mail.com... Recipient ok
data
354 Enter mail, end with "." on a line by itself
Hey
This is test email only

Thanks
.
250 2.0.0 r9M95xgc014513 Message accepted for delivery
quit
221 2.0.0 fbreveal.com closing connection
Connection closed by foreign host.

Thursday, November 17, 2016

Uninstall an Application from the CMD

Open CMD as Administrator:

wmic:root\cli>
product get name (you will see installed software list)
product where name="" call uninstall

For example:

product where name="SkypeT 7.29" call uninstall

Thursday, October 6, 2016

Windows DNS Command Line

Query DNS forest-wide partition replica 
dsquery * "DC=ForestDNSZones,dc=forestRootDomain

Add a CNAME record to DNS 
dnscmd %server% /recordadd %zone% %AliasName% CNAME %HostnameAliasing%

Query zone resource records on a Microsoft DNS server
wmic /namespace:\\root\microsoftdns /node:%server% path MicrosoftDNS_ResourceRecord WHERE ContainerName='%zone_name%'

nslookup with debug information 
nslookup -debug %IP%

DSQuery authorised DHCP Servers
Dsquery * "cn=NetServices,cn=Services,cn=Configuration, DC=forestRootDomain" -attr dhcpServers

Enumerate all records from a DNS zone
dnscmd /enumrecords @ /additional /continue > DNS_all.txt

Lookup SRV records from DNS
nslookup -type=srv _ldap._tcp.dc._msdcs.{domainRoot}

DNS Information
for /f %i in ('dsquery server -domain %userdnsdomain% -o rdn') do dnscmd %i /info

DNS Zone Detailed information
dnscmd /zoneinfo %userdnsdomain%

DNS Zones in AD
for /f %i in ('dsquery server -o rdn') do Dsquery * -s %i domainroot -filter (objectCategory=dnsZone)

Enumerate DNS Server Zones
for /f %i in ('dsquery server -o rdn') do dnscmd %i /enumzones

Print DNS Zones 
dnscmd DNSServer /zoneprint DNSZone

Add a host record in DNS
dnscmd %dnsserver% /recordadd %zone% %relative_name% A %ip%

Find aging records from an enumerated zone
find /i "aging:" DNS_all.txt > DNS_aging.txt

DNS Scavenging check, based on the output of aging records from dnscmd.exe
cscript DNSScavengeTest.wsf /f:DNS_aging.txt

Query DNS objects from the directory
dsquery * DC=,CN=MicrosoftDNS,cn=System,dc=

Start DNS scavenging 
dnsmd /startscavenging

Delete a host record from DNS
dnscmd %server% /recorddelete %zone% @ A %IP%

Determine the DNS suffix search list set through policy for a computer
reg query "\\%Computer%\HKEY_LOCAL_MACHINE\software\policies\microsoft\Windows NT\DNSClient" /v SearchList

Query for the zones hosted on a Microsoft DNS server 
wmic /namespace:\\root\microsoftdns /node:%server% path MicrosoftDNS_Zone

Find DNS Forwarder information from dnscmd output
for %b in (DNS*.txt) do @for /f "skip=2 delims=[]" %i in ('"find /i /N "Forwarders:" %b"') do @for /f "skip=2 delims=[]" %m in ('"find /i /N "Command completed successfully." %b"') do @for /f %p in ('set /a %m-%i') do echo tail -%p %b

List primary reverse lookup zones from a DNS server
dnscmd %server% /EnumZones /secondary /reverse

List allowed secondary servers for the specified zone
dnscmd %server /zoneinfo %ip%.in-addr.arpa SecondaryServers

Source

Thursday, July 7, 2016

Install Telnet Client from CMD

dism /online /Enable-Feature /FeatureName:TelnetClient

Wednesday, April 20, 2016

Upgrade Windows Server 2008 R2 From Standart to Enterprise

View Current installed Version
DISM /online /Get-CurrentEdition

View versions available for upgrade
DISM /online /Get-TargetEditions

for upgrade 
DISM /online /Set-Edition:<edition ID> /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

DISM /online /Set-Edition:ServerEnterprise /ProductKey:489J6-VHDMP-X63PK-3K798-CPX3Y

Restart Computer

Saturday, January 30, 2016

Server Core configuration from CMD

Network Configuration :

netsh
interface
ipv4
show interfaces



Select INx  (name - is selected index) for example 4

set address name=″4″ source=static address=192.168.0.50 mask=255.255.255.0 gateway=192.168.0.1


DNS Configuration:

If there is several dns servers set  index=1,2…

add dnsserver name=″4″  address=192.168.0.10 index=1

exit.

Set Hostname:

netdom renamecomputer WIN-FDP41E28535 /newname:SERVER1

Reboot Computer

shutdown -r -t 0


Join Computer to Domain

netdom join Server1 /domain:contoso.com /UserD:administrator@contoso.com /PasswordD:*


Create Firewall Rule:

netsh advfirewall firewall set rule group=″Remote administration″ new enable=yes

cscript C:\windows\system32\scregedit.wsf  /ar 0


OR Use SCONFIG 







Thursday, January 21, 2016

Shutdown or Reboot Computer CMD and PowerShell

CMD

Shutdown force :

shutdown -s -f -t 0

Restart Force:

shutdown -r -f -t 0


PowerShell :

Stop-Computer -Force

Restart-Computer -Force

Remote Computer :

 Stop-Computer -ComputerName computer  -Credential username -Force

Wednesday, January 13, 2016

Windows Networking CMDs

1. To see your routing table, run either of these commands:
    
    route print

or

    netstat -r

2. To add an entry to your routing table that will be permanent, run the route add command with the –p option. Omitting that, the entry will be lost at next reboot:
    
route add 0.0.0.0 mask 0.0.0.0 172.16.250.5 –p


3. To see all open network connections

    netstat –an

never Launch Startup Repair

bcdedit /set {default} bootstatuspolicy ignoreallfailures