0

Powershell – Read Computergroups and add them on another Computer

Another small script to read the AD Groups of a Computer account and then add the Groups to another Computer. You Need Quest Admin Tools installed, or RSAT. If you use RSAT, just remove the Q in “QADMemberOF” and “QADGroupMember”

$Groups = get-QADMemberOf “WS01$”
$Groups | foreach{
if ($_.name -ne “Domain Computers”) {
  Add-QADGroupMember $_ -Member “WS02$”
}

Where “WS01$” has to be changed to the source Computername, following the $ sign and “WS02$” has to be changed to the Destination Computername, don’t Forget the $ at the End!

 

If you’re just curious about the computergroups, you can get them via Powershell like this:

Get-QADComputer $Computer -Properties Memberof | Select-Object -Expand memberof

 

 

0

Powershell – Show Mapped drives of remote machine (Win8/8.1 only)

Here again one line of code that could be very useful. unfortunately it only works on machines that are on Windows 8 or higher

get-wmiobject -class “Win32_MappedLogicalDisk” -namespace “root\CIMV2” -computername $Computername | Select DeviceID puttygen ,ProviderName

$Computername has to be changed to the machine Name you want to check. As always, local admin rights are needed and the Firewall has to be set correct.

if you Need more Information like size or free space, you can just run the command without the select part:

get-wmiobject -class “Win32_MappedLogicalDisk” -namespace “root\CIMV2” -computername $Computername

 

0

CMD – Run Powershell script with restricted executionpolicy

In Software deployment, you sometimes Need to script stuff. For now, most of the guys I know use Batch files. Because they are easy to use, and they know how to script in Batch. I prefer powershell. But there could be a Problem:

xyz.ps1 cannot be loaded because the execution of scripts is disabled on this System. Please see “get-help about_signing” for more Details.”

This means, that the script you try to run is blocked by your local executionpolicy. You could Change it with Set-Executionpolicy Unrestricted, but for that, you would Need Access to the machine and start powershell as admin. In Addition, you would Need to Change the Setting back after starting the script. There is a better way:

Use cmd: powershell -noprofile -ExecutionPolicy Bypass -File “C:\Path\Script.ps1”

The script now Bypasses the executionpolicy. You can just add the line of code in e.g. your batchfile. puttygen ssh

2

Powershell Toolkit 3.0 Preview

Hi guys

I am working on Powershell Toolkit 3.0 and have already made some significant changes as you will see in the Screens. I will add more functions, and still have a big list of things to do. If you find something you want me to add, give Feedback to this post.

New Functions I added / will add

  • Read Hostsfile
  • Connect AMT via VNC
  • Ping IP V6
  • GPResult
  • Clear Screen
  • Get Usersession
  • Logoff Usersession
  • Get SCCM Cache Size
  • Start all SCCM Cycles
  • Delete local Policy
  • Fix Windows Update
  • GUI Optimizing
  • Changelog
  • Fancy Icons

 

Powershell Toolkit 3 Preview
Preview of Powershell Toolkit 3
puttygen download windows

0

Powershell – Get Hostsfile of Remote Machine and add entries

Reading the hostsfile (Get-Content)

Here is a small script which can read a hostsfile of a remote machine (appropriate Firewall Settings and local admin rights required)

This can all be aquired with only one line of code:

Get-Content “\\$computername\c$\windows\system32\drivers\etc\Hosts”

$computername has to be changed to the machine Name of the remote Computer, eg. ws01

Adding new entries (Add-Content)

To add new entries you can use the Add-Content commandlet:

Add-Content “C:\Windows\System32\drivers\etc\hosts” “`r`n127.0.0.1`t`t`t`tgoogle.com”

This method can be useful for Software Distribution if host entries are required. You can’t use Add-Content commandlet for a remote machine. But there is a solution. Just start a remote Powershell Session (PS Remoting has to be enabled)

Start-Process powershell.exe -ArgumentList “-noexit -command Enter-PSSession -ComputerName $ComputerName”

in this session puttygen download , you can use the Add-Content Commandlet.

 

 

0

Powershell Toolkit 2.0

Powershell Toolkit version 2 is finally finished. I did optimize the code and added some more functions.

Changelog:

  • Added Options Dialog
  • Settings are saved in User Profile and can be exported and imported in / from other Folders
  • Optimized Code
  • Fixed some Bugs
  • Added Multilanguage functions (English and German)

Bugs:

  • Please Report if you find some, most functions should work without Errors.

Download

Screenshots:

Main Screen

0

Powershell Toolkit – Preview

Here is a little preview of my Powershell Toolkit

Version 1.3a Features:

  • Get Computer User
  • Get User Computer
  • Get Home and Profilepath
  • Remote Access with MSRA, Remotecontrol, RDP
  • Remote CMD and Powershell
  • Remote IPConfig, Shutdown
  • Unlock AD User
  • Reset AD Password
  • Wake on LAN
  • Remote Hardware Check (Mainboard, CPU, RAM, USB Device, Printer)
  • Remote Installed Software Check
  • Remote Check Local Admins
  • Remote Computer Management
  • Check Remote Hostsfile
  • Check Remote WLAN Active
  • Get Remote started Processes
  • Get Remote Services, Start / Stop / Restart them
  • Get Remote Harddisk Usage and Condition
  • Remote Reset Offline File Cache
  • Get Remote Mapped Drives
  • Get Remote Eventlog
  • SCCM, Restart Computer and Software indexing
  • SCCM, Get Advertised Software
  • Logging function
  • Integrated Powershell Command Line

Version 2.0 will be finished Q1 of 2015. I will upload the code, a copiled .exe and the Powershell GUI files for editing in Powershell Studio. Any Input is very welcome. I code this by myself in my free time, so expect some bugs. Me and my team use it in my office for helpdesk tasks. Most functions are tested 🙂

Todo for Version 2.0:

  • Optional Settings saved for user, Options contain different default paths and language
  • Optimizing Code and GUI (not that important)

 

Powershell Toolkit Preview Version 1.3
Powershell Toolkit Preview

 

Thanks very much to Francois-Xavier Cat who made the original LazyWinAdmin Toolkit -> http://www.lazywinadmin.com/p/scripts.html#LazyWinAdmin

I used his code PuTTY , made a new GUI with Powershell Studio and added some functions.

 

1 2