Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

Wednesday, December 1, 2021

Using Powershell for the FordPass API

You can use the FordPass for many models of Ford. Is it possible to use Powershell to get the battery status of a eletric car or PHEV? I found some solutions:  

clarkd/fordpass-python: Python wrapper for the FordPass API for Ford vehicle information and control: start, stop, lock, unlock. (github.com)

itchannel/fordpass-ha: Fordpass integration for Home Assistant (github.com)

Both solutions are made in Python. I like to use Powershell. So I made a early version of a script to get the battery status with Powershell:

This is the end result:


In the coming weeks I will test more options from the API and post them here.

Thursday, October 21, 2021

WSUS Part 3: Tuning you WSUS server with Powershell

WSUS Server cleanup

Because the WSUS server uses a lot of storage, it can be useful to clean the WSUS server regularly. This works well if you starts with cleaning regularly after a clean install. When you wait to long and the WSUS server becomes bigger and bigger, it will take a long time to clean the server. In PowerShell you can use this cmdlet:

Invoke-WsusServerCleanUp 

Parameters:

-CleanupObsoleteComputers

Specifies that the cmdlet deletes obsolete computers from the database.

-CleanupObsoleteUpdates

Specifies that the cmdlet deletes obsolete updates from the database.

-CleanupUnneededContentFiles

Specifies that the cmdlet deletes unneeded update files.

-CompressUpdates

Specifies that the cmdlet deletes obsolete revisions to updates from the database.

-DeclineExpiredUpdates

Specifies that the cmdlet declines expired updates.

-DeclineSupersededUpdates

Specifies that the cmdlet declines superseded updates.

-UpdateServer

Specifies the object that contains the WSUS server. This value is obtained by calling the Get-WsusServer cmdlet and passing the resulting IUpdateServer object into this cmdlet.

Example I use for my script:

Invoke-WsusServerCleanUp -CleanUpObsoleteUpdates -CleanupUnneededContentFiles -CompressUpdates


Wednesday, October 13, 2021

WSUS Part 2: Create a task for Patch Tuesday with Powershell

I found out that it is not possible to choose a monthly schedule on the second tuesday of the month with "New-ScheduledTaskTrigger". It is only possible to use a monthly or weekly schedule. Because of this, I used SCHTASKS to create a task for my WSUS PowerShell scripts:

For more information about "New-ScheduledTaskTrigger":


Wednesday, October 6, 2021

WSUS Part 1: Synchronization updates and Approve/Deny updates with Powershell

You can use PowerShell for WSUS management. This example works on a Windows Server with Powershell 5.1 and the Powershell WSUS module installed from Server Manager. You can start the synchronization and approve the updates with the example below:

You can use this example if you like to deny older updates:

All updates are denied when they are older then 4 months.

Sometimes it is necessary to accept a license agreement for an update. You can use this code to accept all license agreements:

Wednesday, September 29, 2021

Password generators for Powershell

There are several ways to create a random password in your PowerShell script. 

Powershell function: 

A function to create an random password string example:


Powershell script:

You can use a this script for more advanced functions:

GitHub - PowerShell random password generator

API:

You can use an API:

GitHub - fawazsullia/password-generator

Example:




Thursday, September 23, 2021

Restore a file with Powershell

Did you delete the wrong file? Need to restore an accidentally deleted file? This Powershell Module
can be the solution:

PowerForensics


PowerForensics is a free Powershell module for forensic research with Powershell. You can use this module for restoring deleted files. Of course there is no guarantee that you can restore it, but you can try it. Check this nice tutorial:

How to Recover Deleted Files from the Drive? | CQURE Academy



Thursday, September 2, 2021

How to create an ISO with Powershell

I don't like to install ISO creation software on every jump or management server. I use a script from this website:


The code is easy to copy to a server in a RDP session or copy a PS1 file to a share and you can run on the server. You don't need any additional modules.


Sunday, August 29, 2021

PowerShell: Download updates from the Microsoft Update Catalog

Download updates from the Microsoft Update Catalog

Most administrators use WSUS for deploying updates on a network. But sometimes it is useful to download stand-alone updates from the Microsoft Update Catalog. I found this PowerShell module:

 https://github.com/ryan-jan/MSCatalog

It is regularly updated and works fine for me. Soon I will post some examples.

Sunday, June 10, 2018

Powershell and System.IO.FileSystemWatcher

I have used FileSystemWatcher for a few script to monitor the filesystem. It is working correct. Only haeavy loads can be a problem because of a buffer overrun. A few useful tutorials I used:

https://mcpmag.com/articles/2015/09/24/changes-to-a-folder-using-powershell.aspx

http://www.mobzystems.com/code/using-a-filesystemwatcher-from-powershell/

Some more information about de buffersize:

https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.internalbuffersize(v=vs.110).aspx


Monday, December 4, 2017

Powershell: Counter with speech



This is a basic counter with speech:

# Making a speech object:
Add-Type -AssemblyName System.speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer

# The counter with speech:
$i = 0 
while( $i -le 100){
  $speak.Speak($i)
  $i++
}


Wednesday, October 12, 2016

WSUS error: Classic,Audit Failure 12-10-2016 08:03:39 MSSQL$MICROSOFT##WID 18456 Logon


I could not start the WSUS management console due to a connection error on the Windows 2012 R2 server. In the Event Viewer I found this error:


Classic,Audit Failure 12-10-2016 08:03:39 MSSQL$MICROSOFT##WID 18456 Logon


More details:


EventID:18456


Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. Reason: Failed to open the explicitly specified database 'SUSDB'. [CLIENT: <named pipe>]


Solution:


Do not uninstall any Windows Updates, but try this first:
  1. Open an elevated Command Prompt and run "C:\Program Files\Update Services\Tools\wsusutil.exe" postinstall /servicing
  2. Enable HTTP Activation under .NET Framework 4.5 Features in the Server Manager Add Roles and Features Wizard
  3. Restart the WSUS service
This solved my problem.

Tuesday, September 27, 2016

Stealing creds from a locked PC using a Hak5 LAN Turtle

Interesting hack explained on Youtube by Hak5:


Stealing creds from a locked PC using a Hak5 LAN Turtle, plus Mubix joins us! This time on Hak5!

The original article can be found at this website::
https://room362.com/ – Mubix’s Site

More links:
https://hashcat.net/hashcat/ – Hashcat
https://crack.sh/ – Crack.sh
https://youtu.be/Vsc-SA0g5Fo – Hak5’s PWM with an Arduino and a Rainbow LED Board

Source:
https://www.hak5.org/episodes/season-21/snagging-creds-from-locked-machines-with-a-lan-turtle-hak5-2104

Tuesday, September 16, 2014

Microsoft Datacenter TCO Analysis Tool

Microsoft Datacenter TCO Analysis Tool.
 
What is it ?
 
The Microsoft Cloud OS solution provides a modern datacenter with enterprise class virtualization, greater resource utilization, end-to-end service management and deep insight into applications so organizations can focus on delivering business value. Together with Windows Azure or a Microsoft Service Provider, you can also create advanced hybrid cloud deployment scenarios where seasonal spikes in demand can be easily managed through the public cloud.

Our web-based tool provides a quick comparison of the TCO and benefits of deploying a Microsoft hybrid cloud vs. a VMware private cloud solution for your new workloads; or migrating your existing VMware workloads.

http://www.datacentertcotool.com/ 

Tuesday, July 22, 2014

Plain Virtualization: vSphere 5.5 Installation with MS SQL Overview

Plain Virtualization: vSphere 5.5 Installation with MS SQL Overview: It has been sometime that I last did any installation and decide to rebuild my home lab.  I will skip the installation or upgrade of ESX s...

I used a part of this article for my own vSphere 5.5 installation with MS SQL server 2008 R2.

Monday, July 21, 2014

Microsoft SQL server 2008 R2 error code 2337 during setup.

I could not start the Microsoft SQL server 2008 R2 setup after this error code. The solution was:

(Step 1 was not required for me!)
1. Save the following in a .reg file and merge to populate the registry:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\100\Bootstrap]
"BootstrapDir"="C:\\Program Files\\Microsoft SQL Server\\100\\Setup Bootstrap\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\100\Bootstrap\Setup]
"PatchLevel"="10.50.1600.00"

2. Next, copy the following files and folders from the media to the specified destinations:


File/Folder in media:   
X64/X86 folder (depending on what architecture you want to install)
Destination:
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2

File/Folder in media:
Setup.exe
Destination:   
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2

File/Folder in media:
Resources folder
Destination:
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2

Next, re-run the setup, and it should proceed beyond the point of error this time.

Source: