PowerShell Install program from UNC path

$Computer = Read-Host -Prompt ‘Set the Name of remote PC’
Enable-WSManCredSSP -Role Client -DelegateComputer “$Computer” -Force

Invoke-Command -ComputerName $Computer -Credential Admin -ScriptBlock {
Enable-WSManCredSSP -Role Server -Force
}

$Setupexe = ‘\Server\folder\setup.exe’
Invoke-Command -ComputerName $Computer -Credential Admin -Authentication CredSSP -ScriptBlock {
echo installing…
& $using:setupexe -S -whatever
}

Disable-WSManCredSSP -Role Client
Invoke-Command -ComputerName $Computer -Credential Admin -ScriptBlock { Disable-WSManCredSSP -Role Server }

Write-Host ‘Finished’

Get AD group members from particular OU of global AD group

Get-ADGroup -Identity MYGROUP_name | Get-ADGroupMember | select name, SamAccountName, distinguishedName | Where-Object { $_.DistinguishedName -like “OU=economy” } | Sort-Object { ($_.’DistinguishedName’ -split ‘,’)[1] } | sort Name

Get computer name where the defined user is logged in

PowerShell:

$Computers = Get-ADComputer -SearchBase ‘OU=computers,OU=Company,DC=name,DC=local’ -Filter * | Select-Object -ExpandProperty Name
$User = “JohnS” foreach ($Computer in $Computers) {
$Sessions = query user /server:$Computer 2>$null
if ($Sessions -match $User) {
Write-Host “$User is logged into $Computer”
}
}

Folders size #powershell

#get size of all folder’s subdirectories in the first level

Bitlocker #bulk computers status

Get information about #bitlocker status if is on or off against list of computers.

#$Computers = get-content -path C:\comps.txt
ForEach ($Computer in $Computers)
{
Invoke-Command -ComputerName $Computer -ScriptBlock {
(Get-BitlockerVolume -MountPoint “C:”).ProtectionStatus } | select PsComputerName, Value
}

Windows 10 reset forgotten local user password

  1. Download Microsoft media creation tool and create boot usb flash or dvd
  2. Boot PC with usb flash/dvd
  3. Switch to recovery mode – run with command line
  4. > cd Windows\System32
  5. > ren utilman.exe utilman.exe.bak
  6. > copy cmd.exe utilman.exe
  7. Reboot PC
  8. Wait until login screen present and click on ease of access
  9. > net user “myLogin” newpassword

10. Here you go with your “newpassword”

WMIC network, #NIC, services

Very simple but useful command wmic #wmic

Last time we’ve learnt, how to run wmic under user profile – (run cmd as different user – Admin).

Today let me show, how to run wmic on the remote machine.

Magic syntax is /node:PC_Name

easy to start/stop local/remote service (for example Themes)

wmic /node:PC001 process call create “net stop/start Themes”

enable/disable particular NIC (as different user, or remotly)

wmic (/node:PCxxx) nic get name, index

wmic /node:PC002 path win32_networkadapter where index=2 call enable/disable

(restart needed)

Zabbix Appliance 4.4.0 # VMWare

Download a .vmdk of Zabbix appliance. Create the new virtual machine. (For me was necessary to change SCSI type to LSI Logic Parallel instead SAS) 😦

1. Login as a root: appliance/zabbix

2. set static IP:

* cd /etc/network
* sudo vi interfaces (make sure to know, how to move in Vi editor)
* iface ens160 (eth0 or ensX) inet static
   set IP, mask, gateway

* sudo /etc/init.d/networking restart

https://www.zabbix.com/forum/zabbix-help/366600-zabbix-appliance-4-0-installation-issues-vmware-esxi-6-5

Check IP:

* ifconfig -a

3. http://ipaddress/zabbix

login: Admin/zabbix

A. create host = server, PC etc. (item = service etc.)

B. add some template (ICMP Ping etc.)

C. create trriger to host or item

D. create an Action (alert e-mail or sms)

Anyway follow the offical Zabbix Documentation 4.4.

 

https://kb.vmware.com/s/article/1022525

 

vmwtools_ubu

 

 

Change Active Directory Group type

Modify Active Directory Group type from Global Security do Domain Local etc.

 

step1:

Get-ADGroup -Filter ‘GroupCategory -eq “Security” -and GroupScope -eq “Global”‘ -SearchBase ‘OU=groups,Ou=domain,DC=domain,DC=local’ | Set-ADGroup -GroupScope Universal

Enter

 

step2:

Get-ADGroup -Filter ‘GroupCategory -eq “Security” -and GroupScope -eq “Universal”‘ -SearchBase ‘OU=groups,OU=domain,DC=domain,DC=local’ | Set-ADGroup -GroupScope Domainlocal

Enter

 

 

Get PC from AD which are not renamed

PowerShell Script which find PC with wrong name.  Default name MiniNT etc.

 

$body = Get-ADComputer -Filter “Name -like ‘minint*'” -SearchBase ‘OU=Desktop,OU=Computers,OU=company,DC=company,DC=local’
If ($body -ne $Null) {
$emailFrom = “alert@mail.com”
$emailTo = “somebody@company.com”
$subject = “Wrong name PC in Active Directory”
$body = $body
$smtpServer = “webmail.com”
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)
}