Rexxer

Some tips for me and other

Windows

Powershell + Mikrotik backups

Source: https://habrahabr.ru/post/351108/ #зададим политику сразу, чтобы не вспминать команду при переносе Set-ExecutionPolicy remotesigned -scope currentuser #установка и импорт библиотеки для ssh Install-Module -Name Posh-SSH Import-Module posh-ssh $curDir = $MyInvocation.MyCommand.Definition | split-path -parent function bkprtr { param($ipaddr) #тут указываем логин и пароль к роутерам с правами на ftp и ssh. $secpasswd = ConvertTo-SecureString “Ваш_пароль_к_роутеру” -AsPlainText -Force […]

Hyper-V + VLANs

Adding VLAN with shell: Add-VMNetworkAdapter -SwitchName Switch -VMName “VmName” -Name “TrunkNic” Set-VMNetworkAdapterVlan -Trunk -AllowedVlanIdList “100,101” -VMName “VmName” -VMNetworkAdapterName “TrunkNic” -NativeVlanId 1

Powershell + Users in OU but not in the groups

import-module ActiveDirectory #$groups = ‘group1′,’group2′,’group3’ $groups = ‘mygroup’ $notpresent = @() $ourset = @{} foreach ($group in $groups) { $members = (get-group $group).members foreach ($member in $members) { if ( !$ourset.contains($member.distinguishedname) ) { $ourset.($member.distinguishedname) = $true } } } get-recipient -OrganizationalUnit MyOU | foreach { if ( !$ourset.contains($_.distinguishedname) ) { $notpresent += $_ } } […]

Powershell + Replace user’s manager

$userobj = Get-ADObject -SearchBase “DC=local, DC=com” -Filter {objectClass -eq “user” -and objectCategory -eq “person” -and manager -eq “CN=manager,DC=local,DC=com”} -Properties name, manager, department foreach ($user in $userobj) { Set-ADObject -Identity $user -replace @{“manager”=”CN=manager2,DC=local,DC=com”} write-host $user.name, $user.manager }

Windows + Remote commands

Psexec from sysinternals suite. WMIC: wmic /node:”servername” qfe get hotfixid | find “KB4012212″, wmic /node:”servername” process call create “cmd /c somecommands” Powershell, run Enable-PSRemoting-Force on the remote PC, run Test-WSMan on your PC to test the connection, run Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } -credential USERNAME Enter-PSSession, as in the #3. Other tools.

Powershell: send and read email

In your Gmail account we have to turn the feature “Less secure app” on. To read mail I used the fine tool for PS: https://github.com/nikoblag/Gmail.ps Script example: #============================================================== # Mail function global:Send-Email ($recipient,$SSubject,$BBody) { $email = “your.mail@gmail.com” $pass = “password” $smtpServer = “smtp.gmail.com” $Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $email, $($pass | ConvertTo-SecureString -AsPlainText -Force) $From […]

CRM 2011 + copy for staging

How to copy Microsoft CRM 2011 organization on the same server. There are many reasons to copy organizations, one of the most common – for testing purpose. You can do as following: Select a database in SQL Server Management Studio which will be copied (TEST_MSCRM). Right click on the target database -> Tasks -> Backup. […]

DNS server + memory consumption

In Windows Server 2008 R2 or older OS with MS08-037 patch installed, DNS server (dns.exe) consumes ridiculously large amount of precious memory. Under the hood, dns.exe opens more than 5000 UDP ports during start up, 2500 for UDP IPv4, 2500 for UDP IPv6.  Large amount of kernel memory is also allocated for these ports.  This can […]

Windows 10 + cannot install Intel Haxm + No VT detection

Disable the group policy setting that was used to enable Credential Guard.On the host operating system, click Start > Run, type gpedit.msc, and click Ok. The Local group Policy Editor opens. Go to Local Computer Policy > Computer Configuration > Administrative Templates > System > Device Guard > Turn on Virtualization Based Security. Select Disabled. […]

Windows 7 + shell commands for consoles

Shell commands list for Windows 7 Обнаружение беспроводных сетей – rundll32.exe van.dll,RunVAN Настройка беспроводной сети – RunDll32.exe shell32.dll,Control_RunDLL NetSetup.cpl,@0,WNSW Управление беспроводными сетями – explorer.exe shell:::{1fa9085f-25a2-489b-85d4-86326eedcd87} Архивация и восстановление – sdclt.exe /restorewizardadmin Восстановление файлов – sdclt.exe /restorewizard Настройка системы архивации – sdclt.exe /configure Добавление сетевого расположения – rundll32.exe shwebsvc.dll,AddNetPlaceRunDll Параметры индексирования – control.exe srchadmin.dll Настройка значков […]

Previous Posts Next posts