Windows

Automatyczne mapowanie dysku vhd podczas startu systemu Windows

Fajna sprawa „dyski” vhd można w łatwy sposób mapować nawet po ścieżce UNC z innego servera zawartość pliku mapowanie_vhd.txt

select vdisk file=”\\net_share\backup.vhd”
attach vdisk
exit

łatwo z poziomu powershella dodać taska mapującego dysk po starcie systemu z opóźnieniem 4 minuty:

schtasks /create /tn „mapowanie_vhd” /tr „diskpart.exe /s 'c:\skrypty\mapowanie_vhd.txt'” /sc ONSTART /ru administrator /rp hasło_administratora /DELAY 0004:00

Eksportowanie virtualek

# skasowanie plików i folderow starszych niz 30 dni
$date = (Get-Date).ToString('dd_MM_yyyy')
# tworzenie folderu - nie wywala bledu nawet jesli istnieje
New-Item -ItemType Directory -Force -Path "E:\BACKUP_VIRTUALKI\"
Get-ChildItem –Path "E:\BACKUP_VIRTUALKI" -Recurse | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-30))} | Remove-Item -Recurse -Force
New-Item -ItemType Directory -Path "E:\BACKUP_VIRTUALKI\$date"
Export-VM -NAME "SERVER01" -Path "E:\BACKUP_VIRTUALKI\$date\"
Export-VM -NAME "SERVER02" -Path "E:\BACKUP_VIRTUALKI\$date\"
Export-VM -NAME "SERVER03" -Path "E:\BACKUP_VIRTUALKI\$date\"
Export-VM -NAME "SERVER04" -Path "E:\BACKUP_VIRTUALKI\$date\"

Kasowanie, Listowanie, wyłączenie kont PC w AD

#ustawienie max wieku komputerów:
$then = (Get-Date).AddDays(-90)

#Wylistowanie tych komputerów, które nie logowały się ostatnio:
Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | FT Name,lastLogonDate

#Wyłączenie kont nieaktywnych komputerów:
Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | Set-ADComputer -Enabled $false

#Usunięcie nieaktywnych komputerów:
Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | Remove-ADComputer

Powershell: directory name must be less than 248 characters

Może się przyda

Udało mi się obejść, prymitywnie, ale udało się, ograniczenie powershella

Mianowicie to: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters

Zamiast: Remove-Item na końcu robię Move-Item do innego folderu i nie wywala błędu długich nazw

A poleceniem dosowe rmdir nie ma problemu z kasowaniem długich ścieżek, plików

[sourcecode language=”powershell”]
Cmd /C "mkdir R:\DO_SKASOWANIA"
Get-ChildItem -Path "R:\BACKUP" | Where-Object { $_.CreationTime -lt (Get-Date).AddDays(-5)} | Move-Item -Destination "R:\DO_SKASOWANIA"
Cmd /C "rmdir /S /Q R:\DO_SKASOWANIA"[/sourcecode]

Outlook – potencjalnie niebezpieczny załącznik

Outlook – potencjalnie niebezpieczny załącznik: mdb; bat; reg lub inne rozszerzenia.

Microsoft Office Outlook 2010:
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Security

Microsoft Office Outlook 2007:
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security

Microsoft Office Outlook 2003:
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security

Microsoft Outlook 2002:
HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security

Microsoft Outlook 2000:
HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Outlook\Security

level1removeWpis dla Outlook 2013:

Windows Registry Editor Version 5.00[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Security]
„OutlookSecureTempFolder”=”C:\\Users\\admin\\AppData\\Local\\Microsoft\\Windows\\Temporary Internet Files\\Content.Outlook\\F1425PCN\\”
„level1remove”=”mdb; bat; reg; vbs;”

Skrypt

Routing Windows 7

Dodanie routingu na interfejs w Windows 7:

route print
=======================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 10 a4 8b 4b 8e ...... Intel(R) PRO/100+ MiniPCI - Packet Scheduler Miniport
0x4 ...44 45 53 54 42 00 ...... Nortel IPSECSHM Adapter - Packet Scheduler Miniport
0x20003 ...00 04 5a 0c 96 db ...... Instant Wireless - Network PC CARD #2 - Packet Scheduler Miniport
=======================================================================
route -p add 0.0.0.0 mask 0.0.0.0 192.168.1.1 metric 1 if 0x20003

Źródło: http://windowsitpro.com/networking/q-when-i-add-static-ip-route-what-value-do-i-use-interface