[PS] Top Ten Simple Powershell commands every IT-admin should know

Welcome everyone!

Today i’m going to share my top 10 (beginner-friendly) Powershell commands that i use quite frequently.

I hope that you will find these commands useful.

 1. Connect to a remote computer:

Enter-PSSession -ComputerName "Computer1"

 

2. Get events from EventViewer:

Get-WinEvent -computername "Computer1" -FilterHashTable @{ LogName = "System"; StartTime = "2020-02-12"}

 

3. Get OS BuildNumber:

Get-WmiObject -Class Win32_OperatingSystem -ComputerName "Computer1" | Select BuildNumber

 

4. Get OS ReleaseID:

(Get-ItemProperty -Path ‘HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion’).ReleaseId

 

5. Get values from the registry:

Get-ChildItem -Path 'HKLM:\PATH\TO\KEY'

 

6. Set values in the registry:

New-ItemProperty -Path "Registry::\HKEY_CURRENT_USER\PATH\TO\KEY\" -Name 'Flags' -PropertyType DWORD -Value "1337"

 

7. Show the latest installed updates (KB’s):

(Get-Hotfix | sort installedon)

 

8. Get serialnumber (CimInstance):

(Get-CimInstance -ClassName Win32_BIOS).Serialnumber

 

9. Get Bios version (CimInstance):

(Get-CimInstance -ClassName Win32_BIOS).SMBIOSBIOSVersion

 

10. Get computer model (CimInstance):

(Get-WmiObject Win32_Computersystem).Model

 

Comment down below if you have any questions! 🙂

Home Assistant – How to configure the SMTP component (Gmail)

Morning guys!

Today im going to show you how to configure the SMTP-component so that you can send e-

mails from Home Assistant! My other article shows some examples of what you can use the SMTP-component for.

  1. The first thing that you have to do is enable the SMTP-component – start by copying the code below and add it to your configuration.yaml file.

Make sure to change sender, username, password and recipient before you save your configuration. If you use another provider than gmail you will have to change the smtp-server and port also.

Another heads-up is that if you have 2-factor authentication enabked on your Google account you’ll need to create an app password to use instead of your ordinary password – how do i create an app password?

 

SMTP-component:

notify:
  - name: gmail
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 15
    sender: FROM@gmail.com
    encryption: starttls
    username: FROM@gmail.com
    password: SECRETPASSWORD
    recipient:
      - TO@gmail.com
    sender_name: Home Assistant

 

2. Restart Home Assistant (make sure that you don’t get any errors after the reboot)

Done! Now you can use this in your automations to notify you about stuff!

This article covers how you can send notifications base on the state of your robot vacuum

 

 

Home Assistant – Roborock Automations

Hello Roborock enthusiasts!

In this little guide i will share with you how to get the most basic notifications from your Roborock vacuum using automations.yaml in Home Assistant!

I will add more automations as i keep using the Roborock S5, so stay put on some more useful automations!

 

You will need the following:

Make sure to change notify.ios_device to your own notification service.

And then add the following to your automations.yaml file and restart Home Assistant.

Cleaning started:

- id: 'Vacuum_started'
  alias: Vacuum Started Notification
  trigger:
  - entity_id: vacuum.xiaomi_vacuum_cleaner
    from: docked
    platform: state
    to: cleaning
  condition: []
  action:
  - data:
      message: Roborock started to clean!
    service: notify.ios_device

Cleaning completed:

- id: 'Vacuum_complete'
  alias: Vacuum Complete Notification
  trigger:
  - entity_id: vacuum.xiaomi_vacuum_cleaner
    platform: state
    to: docked
  condition: []
  action:
  - data:
      message: Cleaning complete - Charging
    service: notify.ios_device

 

For more information about how to get started with Home Assistant click the link below:

https://www.home-assistant.io/getting-started/

Office Addin Manager

Hello!

Once again i’ve created another Powershell (XAML) application.

This time i’m releasing Office Addin Manager, which allows you to manage Office addins on your own or a remote computer. As always, changing registry settings on a remote computer requires you to have administrative permissions on that computer.

With this tool you can in a quick manner change the load behavior of Office addins no matter the Office application, no more messing around in regedit or manually open each Office application.

Office Addin Manager uses a number of different values to configure each addin to run with a specific behavior. Read more about load behavior values on docs.microsoft.com

 

Download

If you have any questions feel free to ask them below, i’m more than happy to answer them 🙂

AD Extractor – Extract members of AD group with a simple tool!

Morning everyone!

With the basic code from Vikas Sukhija i created this GUI around Vikas code. Mainly to help more people utilize his code (that aren’t comfortable around code), but also so that i could reduce the amount of clicks.

The full source is available here if you don’t want to download the .exe

 

What does AD Extractor do?

AD Extractor is using ADSI to search the AD. You can extract members from both security and distribution groups. There is also no problem with extracting computers and/or users from a group. I added a simple GUI so that you could export a complete list with just 2 clicks. You obviously need the appropriate permissions to run this program. As for now you can only export a list to .txt, but in the future i will add .csv support (if there is a demand for that)

 

Download

 

If you have any questions or feedback you are more than welcome to post that in the comments below.

Have a great day! 🙂

[Registry] How to Restore Windows Photo Viewer in Windows 10

Hi everybody! 

Are you tired of the Windows 10 Photo app? Or simply want to change back to the old photo viewer?

In this post i’m going to show you how to get the Photo Viewer (formerly Windows Picture and Fax Viewer) back in Windows 10.

There are several articles out there that show you how to do this, some that i’ve tried worked, some did not.

Anyway, these registry keys is needed, and no reboot is required.

 

How it’s done:

  1. Download this .reg file (or copy/paste the raw code from pastebin)
  2. Unzip RestorePhotoViewer.reg
  3. Run the .reg file, and press Yes to continue
  4. Now you can associate images files with the classic Photo Viewer

 

I have only verified this to work in 1709 and 1803 only, comment down below what other release ids it works/doesn’t works on.

Modifying the registry could create problems on your computer, so please make sure that you know what you’re doing when running .reg files.

How to Reset the Color of the Command Prompt in Windows 10

Hi everyone!

Recently bumped into an issue regarding the classic command prompt (CMD).

 

Problem:

CMD colors are changed so that you are unable to see the text, and cannot change back (for whatever reason)

 

Solution:

Change the REG_DWORD DefaultColor to “7

HKEY_CURRENT_USER\Software\Microsoft\Command Processor
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Command Processor' -Name DefaultColor -Value "7"

 

Voila!

Procmon saves the day!

 

Retrieve full download URL in Google Chrome

Hello geeks!

What do you do when the Copy link address button isn’t there?

Today i’m going to show you how to retrieve the full download URL (with file extension) for any download in Google Chrome. WGET for example requires the “true” download url, with file extension in order to download the file.

I’m guessing that you’ve already know that you can press “Copy link address” on many Download buttons to retrieve the download URL, if not, know you know.

 

But what if you’re not seeing the “Copy link address” button, like this?

Or what if the link you get when pressing Copy link address is a redirect or just not the direct download path to the file?

Then you simply do this:

  1. Press the Download button
  2. Open Downloads (CTRL + J)
  3. Right click the downloaded file, and press copy link address

 

Or if you want to dig down deeper, you could extract the URL using inspect-mode:

    1. Start Google Chrome, and have your download button ready, don’t press it yet.
    2. Open Inspect-mode (CTRL + SHIFT + I)
    3. In Inspect-mode, select Network
    4. Press your Download button
    5. Now immediately after, press Stop recording network log (CTRL + E)
    6. Now you should see the raw file under Name, in this example ChromeSetup.exe
    7. Right click on ChromeSetup.exe -> Copy -> Copy link address (see picture below)
    8. Now you should have copied something like this https://website.com/file.exe

I hope that this was helpful & feel free to comment down below if you have any questions 🙂

 

1 0

 

[HA] Schedule switches or lights in Home Assistant with automations.yaml

Hello!

If you want to schedule stuff to turn on or off at a specific time of the day, you will need to use automations.yaml.

Don’t forget to specify where the automations.yaml file is located in your configuration.yaml file.

The following code below is correctly-formatted, with the right amount of spaces in front of every line – which is very important.

So feel free to copy the text below, and change Alias, At, Entity and Service to better fit your needs.

configuration.yaml

automation: !include automations.yaml

automations.yaml

  - alias: "Name of this automation"
    trigger:
      platform: time
      at: '21:30:00'
    action:
       service: switch.turn_off
       entity_id: switch.light