Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Monday, June 26, 2023

PS Scripts - Set Windows Registered User and Organization


Here's a quick and easy PowerShell script to set Windows registered owner and organization. The script will automatically set the owner as the logged user.

Tip: Use it during Autopilot deployment so you can have this information automatically added after the assigned user sign-in.

Wednesday, January 16, 2019

Powershell Tips – How to know installed Powershell version

Need to know which version of Powershell you’re using?

As easy as:

  1. Open an elevated Powershell console

  2. Run the follow command:
    $PSVersionTable

  3. You’ll get a complete list of installed versions for each module:

Thursday, October 19, 2017

Win10 Deploy – v1709 (Fall Creators Update) – You’ll Need to Change Your “RemoveApps” Script!

This new paradigm of Windows as a Service (Waas) really makes SysAdmins to change the way they work and also adapt really really quick.

Following the release of Windows 10 v1709 (Fall Creators Update), and if like me you use a Powershell script to remove provisioned apps during image deployment or golden image creation, you’ll notice…a lot of broken things on you script.

This happens because of changes on the apps version…so…or you create a more complex script that just looks for the beginning of the application string or you adapt your script to this new release.

So…you try to install you golden image with Microsoft Deployment Toolkit (MDT) and you get the following error when finishing:
getappx2

Now…don’t close this Window right yet. Instead, follow this steps:

  1. Open a Powershell prompt
  2. Execute the following command: Get-AppxPackage –Online > C:\Apps.txt
  3. This will create a file called Apps.txt on you C: drive with all the installed/provisioned apps. It will be something similar to this:
    getappx
  4. Now you just need to copy/paste the updated “PackageName” to your script and everything works fine again.

Just a quick note to remember that for example Microsoft 3DBuilder app was removed from Windows 10 v1709 so you may completely remove that line from your script.

Tuesday, September 12, 2017

Powershell Tips – Get Users and Group from a GPO Security Filtering

image

Using security filtering on GPOs it’s a nice way to apply a GPO to specific groups or users.
But you may find yourself a little bit lost if you need to know every user or group you have configured.

Since Group Policy Management doesn’t allow you to export the users and groups, you’ll need to use a Powershell command to do it.

Here’s how:
Get-GPPermission Name ‘GPO NAME’ -All | Where Permission –eq GpoApply

And…you’re done!

Thursday, December 8, 2016

PS Scripts–Add to Path Environment Variable

Here’s an easy and quick way to add a string to your Path environemnt variable:

[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\SomethingYouLike", [EnvironmentVariableTarget]::Machine)

And…you’re done! ;)

Thursday, November 17, 2016

PS Scripts – Change Windows Service Logon Account

Need to change a Windows Service logon account with Powershell?
Here’s an easy and quick way to do it:

$strSvcStartScr = Get-WmiObject win32_service -Filter "Name='browser'"
$strSvcStartScr.Change($null,$null,$null,$null,$null,$false,’domain\username’,'password') | Out-Null

All you’ve to do is change the service name on the first line and the domain/username and password on the second.

And….your done!

Wednesday, November 9, 2016

VMware PowerCLI Scripts – Get ParentVM used on Pools

In the last days I needed to get a quick view of which templates we’re using on enviroments. Because we have linked clones, our pools have configured a ParentVM and the respective Snapshot.

If you have a large environment after a while you may miss a little bit control of which templates/parent vms are really being used, which ones were just for testing purposes and you don’t need them anymore, etc.

So, for a quick look at your environment and to understand which parent vms each pool is using just follow these steps:

  • First you’ll need to open View PowerCLI on the correspondent Connection Server
  • Then, run the following command:
    Get-Pool
  • As simple as that, you’ll get all info from each pool
  • If you want something like that but, with less information use the followin command:
    Get-Pool | Select pool_id, displayName, enabled, vcServerName, parentVMPath, parentVMSnapshotPath
  • Like in any powershell script or command, you can always export the results to a csv file to work it up later:
    Get-Pool | Select pool_id, displayName, enabled, vcServerName, parentVMPath, parentVMSnapshotPath | export-csv D:\export.csv

And…it’s done! :)

Thursday, May 15, 2014

VMware PowerCLI - Change Pool AutoLogoff Behavior


VMware PowerCLI for View it's a very handful tool if we need to administer a big number of VMware Horizon View pools.
Very similar/based on Microsoft Powershell, VMware PowerCLI allows to run commands directly to VMware View and running scripts also.

Here's a nice one to change a pool's behavior for AutoLogoff after a user's disconnect from a machine.
The script reads a text file that only have the PoolID for all pools that you want to change:

#*********************************************************************
# Application: Change Pool AutoLogoff Timeout From List
#
# Overview: Changes the pool autologoff timeout from a given list
#
#*********************************************************************

$sourcevms = "C:\Pools.txt"
$list = Get-Content $sourcevms

foreach($item in $list){
 Get-Pool -Pool_id $item | Update-AutomaticLinkedClonePool -AutologoffTime 30
}