I needed to modify some text somewhere in a file. The file looks like this ## start file This is some text. I want to change something. But not this. ## end file I was playing around with various options. The simplest I found was this: £> $txt = Get-Content .\test.txt £> […]
Archive for January, 2015
Testing for a hotfix
Posted by: richardsiddaway | January 30, 2015 Comments Off on Testing for a hotfix |KB3000850 – the November roll up for Windows 2012 R2 contains some very useful updates. I’ve installed it on some machines in my lab but not all. The update is huge so I’m installing it manually rather than through WSUS. I need to test a remote machine to determine if the update is installed. […]
I was working on some code that accesses a SQL database this afternoon. I only needed to pull back a single column from a single row but which column to pull back is variable depending on other data. That’s OK $query = “SELECT $colname FROM tablename WHERE x = ‘y’” Invoke-SQLcmd –server <server> –database <database> […]
Most PowerShell users will have done something like this: £> Get-WmiObject -ClassName Win32_ComputerSystem Domain : WORKGROUP Manufacturer : Microsoft Corporation Model : Surface Pro 2 Name : RSSURFACEPRO2 PrimaryOwnerName : TotalPhysicalMemory : 8506093568 Or you can use a computername to access a remote system £> $computer = $env:COMPUTERNAME £> Get-WmiObject -ClassName Win32_ComputerSystem -ComputerName $computer […]
Unravelling lists of distinguished names
Posted by: richardsiddaway | January 26, 2015 Comments Off on Unravelling lists of distinguished names |There are a number of AD properties such as MemberOf and directrports that consist of a collection of distinguisednames. Sometimes you need the name of the object rather than the distinguished name: function getname { [CmdletBinding()] param ( [string]$dn ) $name = Get-ADObject $dn | select -ExpandProperty Name return $name } Get-ADUser -Filter * -SearchBase […]
Filtering on if an AD property exists
Posted by: richardsiddaway | January 26, 2015 Comments Off on Filtering on if an AD property exists |There are times when you want to filter the results based on whether a user has an AD property set. You could do this: Get-ADUser -Filter * -Properties Title | Where Title | select Name, Title However, that involves pulling back all of the users and then filtering. Not very efficient especially across the […]
Awkward file and folder names
Posted by: richardsiddaway | January 21, 2015 Comments Off on Awkward file and folder names |Spent some time today dealing with a situation where there were special characters – namely [ ] in folder a file names £> Get-ChildItem -Path C:\Test Directory: C:\Test Mode LastWriteTime Length Name —- ————- —— —- d—- 21/01/2015 17:58 Awkward [One] d—- 21/01/2015 17:59 Simple One Each folder has 3 files: File 1.txt […]
PowerShell Summit NA 2015 Agenda changes
Posted by: richardsiddaway | January 18, 2015 Comments Off on PowerShell Summit NA 2015 Agenda changes |We’ve had to make some minor changes to the Summit agenda – the revised schedule is shown on the event web site – http://eventmgr.azurewebsites.net/event/home/PSNA15
PowerShell Heroes 2015
Posted by: richardsiddaway | January 18, 2015 Comments Off on PowerShell Heroes 2015 |Powershell.org has announced the 2015 list of PowerShell Heroes- http://powershell.org/wp/2015/01/17/announcing-our-2015-powershell-heroes/ These are people who have made an outstanding contribution to the PowerShell community but have not been recognised in other ways (such as an MVP award) Please join me in congratulating them
You can use Get-EventLog to query the event logs on you system Get-EventLog -LogName System One frequent task is to check if events occurred during a specific timespan. You may feel that you need to use a where-object filter to do this but there is a simple method. Get-EventLog -LogName System -After (Get-Date -Date […]
Categories
- .NET
- Active Directory
- Architecture
- Azure
- Bash
- BITS
- Books
- CDXML
- CIM
- Cloud
- COM
- Containers
- Deep Dive
- Desired State Configuration
- DevOps
- DHCP
- DNS
- DSC
- European Summit
- Events
- Exchange
- File System
- Firewall
- General
- General IT Matters
- Hyper-V
- IIS
- Infrastructure
- IT Community
- IT Security
- Learning PowerShell
- Linux
- Math
- Microsoft
- Modules
- Nano Server
- Networking
- Office 2010
- Office 2013
- Open Source
- Opinion
- Outlook
- Philosophy
- PowerShell
- PowerShell 7
- PowerShell and .NET
- PowerShell and Active Directory
- PowerShell and CIM
- PowerShell and Exchange 2007
- PowerShell and IIS
- PowerShell and SQL Server
- PowerShell and WMI
- PowerShell Basics
- PowerShell original
- PowerShell Summit
- PowerShell User Group
- PowerShell User Group 2
- PowerShell v2
- PowerShell V3
- PowerShell v4
- PowerShell v5
- PowerShell v6
- PowerShell.org
- PowerShellGet
- PowerShellV2
- PSAM
- Rant
- Registry
- Scripting
- Scripting Games
- Scripting Games 2104
- Security
- SQL Server
- Storage
- Strings
- Summit
- Technology
- Uncategorized
- Virtualization
- Windows 10
- Windows 2012 R2
- Windows 7
- Windows 8
- Windows 8 Server
- Windows 8.1
- Windows Server
- Windows server 1709
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows Server 2016
- Windows Server 2019
- WMFv5
- WPF
- WSUS