cmd.exe /c diskpart /s "%scriptroot%\changepart.txt"
changepart.txt could looks like below:
select disk 1
online disk noerr
attributes disk clear readonly noerr
select volume 0
assign letter=Z noerr
select volume 2
assign letter=D noerr
exit
I write some useful information and lessons learnt about SCCM, MDT, SCOM, Exchange, Lync, Windows 7/8, Windows servers, Hyper-V, Vmware
Szukaj na tym blogu
wtorek, 21 stycznia 2014
Rename administrator account using powershell script
powershell.exe -Command "set-ExecutionPolicy RemoteSigned -Force; cpi '%DEPLOYROOT%\Applications\RenameAccounts\RenameAccounts.ps1' -destination c:\; c:\RenameAccounts.ps1; ri c:\*.ps1 -Force"
Reboot remote computers
Tested psshutdown.exe and there is a problem on 64bit machines - the message for users is not displayed. This is known case (http://forum.sysinternals. com/psshutdown-no-message- displayed_topic21119.html) Good to know before trying to do it on production:)
We can workaround this using
PsExec.exe -d -i 1 -u admin -p P@ssw0rd \\10.176.6.171 "c:\windows\system32\shutdown. exe" -r -f -t 3600 -c "Your computer will reboot within one hour. You can reboot it by Yourself now if You are ready"
PsExec.exe -d means non-interactive
PsExec.exe -i is the number of session in which message will be displayed (users usually are loged in to session 1 also if they are connected via RDP)
I tested it on Windows 7 both 32 and 64 bits machines.
wtorek, 14 stycznia 2014
Ping list of computers and get shor information
$comp = gc "ips.txt"
$ping = new-object system.net.networkinformation.ping
$pingreturns = @()
foreach ($entry in $comp) {
$pingreturns += $ping.send($entry)
}
$pingreturns | ? {$_.status –eq “success”} | select address
$ping = new-object system.net.networkinformation.ping
$pingreturns = @()
foreach ($entry in $comp) {
$pingreturns += $ping.send($entry)
}
$pingreturns | ? {$_.status –eq “success”} | select address
Get list of computers which have c$ share
Get-Content "list_ip.txt" | `
Select-Object @{Name='ComputerName';Expression={$_}},@{Name='Can access c$';Expression={ Test-Path "\\$_\c$"}}
Select-Object @{Name='ComputerName';Expression={$_}},@{Name='Can access c$';Expression={ Test-Path "\\$_\c$"}}
piątek, 10 stycznia 2014
Script for getting information regulary from website, grep for text and send email if something
First need to download wget, grep and mailsend (https://code.google.com/p/mailsend/downloads/list) for windows
cd "C:\Program Files (x86)\GnuWin32\bin"
wget -O c:\windows\temp\%date%.html --no-check-certificate http://www.websiteaddress.com
cd "C:\Program Files (x86)\GnuWin32\bin"
grep "Bartlomiej" "c:\windows\temp\%date%.html" >> "c:\windows\temp\%date%.txt"
cd "C:\Program Files (x86)\GnuWin32\bin"
set /p var=
mailsend.exe -smtp smtp.gmail.com -port 465 -t username@gmail.com -f username@gmail.com -sub CheckBet -v -ssl -auth -user username@gmail.com -pass PASSWORD -attach c:\windows\temp\%date%.txt
cd "C:\Program Files (x86)\GnuWin32\bin"
wget -O c:\windows\temp\%date%.html --no-check-certificate http://www.websiteaddress.com
cd "C:\Program Files (x86)\GnuWin32\bin"
grep "Bartlomiej" "c:\windows\temp\%date%.html" >> "c:\windows\temp\%date%.txt"
cd "C:\Program Files (x86)\GnuWin32\bin"
set /p var=
mailsend.exe -smtp smtp.gmail.com -port 465 -t username@gmail.com -f username@gmail.com -sub CheckBet -v -ssl -auth -user username@gmail.com -pass PASSWORD -attach c:\windows\temp\%date%.txt
Subskrybuj:
Posty (Atom)