Visual Studio Project To cURL A REST Endpoint in C++

Published a new Visual Studio project for running rest operations against an endpoint using C++ or Visual C++. That’s available at https://github.com/krypted/C-cURLer.

Note: When you compile the project, you will need to add the dependencies so check what’s being imported before doing so.

Get A List Of Software Installed On Windows And Uninstall Software Using Powershell

The Get-AppxPackage cmdlet can be used to obtain a list of all apps installed on a Windows host. In the following example, we’ll look at the apps installed for all users using the -AllUsers option.

Get-AppxPackage -AllUsers

The output includes a Name, the name of the publisher, along with a location, the architecture, the version, the full name, the status, whether the software is signed, whether the development mode is enabled (useful when testing), the id of the publisher, the family, etc.

Next we’ll do a Select against the found set. You can use so stdout displays the Name and the unique identifier, which we can then use to programmatically work with the package if needed (you can choose any of the metadata from the previous command in the select):

Get-AppxPackage -AllUsers | Select Name, PackageFullName

If you want, you can use -User instead of -AllUsers, to see the output of just a given package. One challenge with using Get-Appxpackage is that you don’t get the actual “Product Name” so if you, for example, wanted to uninstall a program, you’d need to hop into WMI. First, let’s use gwmi to find a product with the word Krypted in the name:

$Key = Get-WmiObject -Class Win32_Product | Where-Object {
$_.Name -match "Krypted"
}

Next, let’s use the $Key from the output to uninstall the software:

$Key.Uninstall()

Quick And Dirty Windows Firewall Scripting

Here ya’ go! netsh advfirewall firewall add rule name=”KryptedWebhook” dir=in protocol=tcp localport=8443 profile=private remoteip=any action=allow Wait, what’s that?!?! Let’s break down the options I used here:
  • advfirewall: Yup, it’s the new firewall.
  • firewall: Yup, it’s a firewall.
  • add: I’m adding a new rule. I also could have used delete along with the rule name and removed one. Or show to see one. Or set to augment one.
  • rule: It’s all about rules. Each rule allows for a port and/or an action.
  • name: Every rule needs a unique name. Namespace conflicts will result in errors. If programmatically creating rules, I’ve found it undesirable to use a counter and instead moved to using GUIDs and a hash table.
  • dir: The direction traffic is flowing. In is for incoming traffic or out would be to block outgoing traffic.
  • protocol: Use the protocol, typically tcp or ump, but if pings, might be one of the icmps.
  • localport: The port that is being used (there’s also a remoteport operator for reflections).
  • profile: I mostly use profile of private.
  • remoteip: Set to any but could be set to a given IP for increased security (yes, I know people can spoof these – so your version of the word might be different.
  • action: I used allow, but could have been block (which denies traffic) or bypass.
For further security, I might add a security operator, to allow for an authentication string. You can You might also need to allow traffic for a given app. To do so, let’s add a rule that does so, the only option for which not mentioned above is program, which is the path to the binary we’re allowing: netsh advfirewall firewall add rule name="My Application" dir=in action=allow program="C:\kryptedscripts\kryptedcompiledwebapp.exe" enable=yes To then see the rules and validate that your rules were indeed installed, use: netsh advfirewall firewall show rule name=all The reason I call this quick and dirty is that I’m really only covering a small subset of options. Additionally, it would be a bit more modern to do this via powershell using New-NetFirewallRule or one of the many, many other commandlets, such as Copy-NetFirewallRule, Enable-NetFirewallRule, Disable-NetFirewallRule, Get-NetFirewallAddressFilter, Get-NetFirewallApplicationFilter, Get-NetFirewallInterfaceFilter, Get-NetFirewallInterfaceTypeFilter, Get-NetFirewallPortFilter, Get-NetFirewallRule, Get-NetFirewallSecurityFilter, New-NetFirewallRule, Open-NetGPO (cause you can configure the firewall through a GPO), Remove-NetFirewallRule, Rename-NetFirewallRule, Save-NetGPO, Set-NetFirewallRule, Set-NetFirewallSetting, and Show-NetFirewallRule.

Disable Notification Center & Action Center in Windows 10

A number of environments need to disable the Notification Center and Action Center features in Windows 10. This can be done using the registry editor or using a Group Policy Object (GPO). First let’s look at doing so with the registry. As with any mucking around with the registry, when editing, I strongly recommend backing up the registry and/or creating a restore point first. Once done, click Run, enter regedit and hit Enter to open the Registry Editor. Next, right-click on the HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer registry key and create a new DWORD (32-bit) key. Call the key DisableNotificationCenter and provide the number 1 as the value. Then quit the Registry Editor and restart. Notification Center and Action Center should then be disabled. Simply delete that key and reboot in order to go back. If the Group Policy Editor is available, click Run and enter gpedit.msc. Then open the User Configuration, navigate to Administrative Templates, click on Start Menu and then choose Taskbar. Open Remove Notifications and Action Center, and move the Enabled option to Disable (if disabling of course). You can then run gpupdate or reboot to see the change.

Remotely and Silently Install A Windows MSI Via PowerShell

One of the easiest things to do in OS X is to remotely run an installation package using the installer command. You can do some similar tasks in Windows, although the commands aren’t quite as cut and dry. The Start-Process command can be used to kick off an executable. Here, we will kick off the msiexec.exe and feed it an argument, which is the msi file to install silently. We’ll then wait for it to complete: {Start-Process -FilePath "msiexec.exe" -ArgumentList "/i TEST.msi /qb" -Wait -Passthru}

Package Manager Like apt-get For Windows 10

In Windows 10, Microsoft has finally baked a package manager called OneGet into Windows. It works similarly to apt-get and other package managers that have been around for decades in the Linux world; just works in PowerShell, rather than bash. So let’s take a quick peak. First, import it as a module from a PowerShell prompt: Import-Module -Name OneGet Next, use Get-Command to see the options for the OneGet Module: Get-Command -Module OneGet This will show you the following options: Find-Package Get-Package Get-PackageProvider Get-PackageSource Install-Package Register-PackageSource Save-Package Set-PackageSource Uninstall-Package Unregister-PackageSource Next, look at the repositories of package sources you have: Get-PackageSource You can then add a repo to look at, using Register-PackageSource. Or, we’ll just fire away at locating our first package, Acrobat: Find-Package -Name AdobeReader Or you could pipe that output to the Install-Package option: Find-Package -Name AdobeReader | Install-Package Or Firefox, verbosely: Install-Package -Name Firefox -Verbose Or ASP.NET MVC silently (using -Force): Install-Package Microsoft.AspNet.Mvc -Force In some cases, you can also use the -Version option to define a specific version, which is why I ended up writing this in the first place – swapping between versions of asp has been a bit of a pain since the introduction of its first update, it seems… PowerShell logo

Kill Windows Processes In Windows 8

You can gracefully stop Windows processes using the Stop-Process command let. For example, to stop Chrome: Stop-Process -Name Chrome Or to stop it by ID. To locate the ID of a process, use get-process: get-process Chrome You can then use the -ID operator to stop the process: Stop-Process -ID 6969 Kill is a command that all Mac and Unix admins know. It’s similar to Stop-Process, except it’s anything but graceful. And you use the -processname option to stop a process: kill -processname calc

Enable AutoAdminLogon For Windows Deployments

There are 3 registry keys that admins in the Windows world use to enable automatic logins, often required for deployments that require a logged in user to setup user environments, such as configuring app deployments as part of a mass deployment. The required keys in the registry are: Continue reading Enable AutoAdminLogon For Windows Deployments

Get The Current Logged In User From The Windows Command Line

You can get the currently logged in user from a powershell script by using $env:username. But most deployment scripts use elevated privileges. Therefore, you need to be a tad bit craftier. Continue reading Get The Current Logged In User From The Windows Command Line

Yosemite Server SMB and Windows

A few people have hit me up about issues getting Windows machines to play nice with the SMB built into Yosemite Server and Windows. Basically, the authentication dialog keeps coming up even when a Mac can connect. So there are two potential issues that you might run into here. The first is that the authentication method is not supported. Here, you want to enable only the one(s) required. NTLMv2 should be enabled by default, so try ntlm: sudo serveradmin settings smb:ntlm auth = "yes" If that doesn’t work (older and by older I mean old as hell versions of Windows), try Lanman: sudo serveradmin settings smb:lanman auth = “yes" The second is that the authentication string (can be seen in wireshark) doesn’t include the workgroup/domain. To resolve this, simply include the Server name or workgroup in the beginning of the username followed by a backslash(\). So you might do this as a username if your NetBios name were kryptedserver: kryptedserver\charles To get that exact name, use serveradmin again, to look at the smb:NetBIOSName attribute: smb:NetBIOSName = "kryptedserver"