The Get-Date -UFormat parameter formats the date using Unix format. The full list of format specifiers are in the Notes section of the Get-Date help file. Some examples are: PS> Get-Date -UFormat ‘%Y-%m-%d %H:%M%:%S%Z’ 2019-05-27 20:40:11+01 4 digit year – two digit month and day. Hour in 24 hour format and minutes and seconds […]
Archive for May, 2019
Get-Date –Format enables you to control the formatting of the datetime object returned by the cmdlet. A standard call to get date returns: PS> Get-Date 27 May 2019 12:36:47 The –Format parameter takes a value from the DateTimeFormatInfo class – https://docs.microsoft.com/en-us/dotnet/api/system.globalization.datetimeformatinfo?view=netframework-4.8 – to specify how you want the information to be formatted. For instance: Short and long […]
PowerShell has a number of logical operators – – -and, –or, –not (or !). One I’ve really thought about is the exclusive OR operator –xor. With a standard –or operator the result is TRUE if one of the statements is TRUE PS> (‘a’ -eq ‘A’) -or (‘a’ -eq ‘z’) True The standard –or operator is also […]
PowerShell provides easy access to some useful constants. I often see people calculating these values rather than using the constants. PowerShell recognises kb, mb, gb, tb and pb for kilobyte, megabyte, gigabyte, terabyte and petabyte respectively. You can use them like this: PS> 1kb; 1mb; 1gb, 1tb, 1pb 1024 1048576 1073741824 1099511627776 1125899906842624 Don’t […]
Articles published in 2019
Posted by: richardsiddaway | May 25, 2019 Comments Off on Articles published in 2019 |I’ve had the following articles published in 2019 https://searchwindowsserver.techtarget.com/tutorial/Set-up-users-with-key-PowerShell-Active-Directory-commands https://searchwindowsserver.techtarget.com/feature/Editing-content-with-Windows-PowerShell https://searchwindowsserver.techtarget.com/tip/Windows-Compatibility-module-expands-PowerShell-Core-reach Enjoy
In Windows PowerShell if you do something like this: PS> (1..20 | Sort-Object -Property {$_ % 3}) -join ‘ ‘ 9 6 12 15 3 18 19 16 13 10 4 1 7 20 17 2 8 11 5 14 The results come back in an unexpected order. This is not a stable sort […]
OpenSSH installation
Posted by: richardsiddaway | May 25, 2019 Comments Off on OpenSSH installation |OpenSSH installation has got a lot simpler in Windows 10 1809; Windows Server 2019 and Windows Server 1809. OpenSSH is available as an optional feature. The client is preinstalled when you install the operating system. You just need to install the server: Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 Installing the optional feature creates the required […]
Create a symbolic link
Posted by: richardsiddaway | May 23, 2019 Comments Off on Create a symbolic link |I recently had to create a symbolic link to overcome a bug in OpenSSH whereby OPENSSH won’t work with the path C:\Program Files\PowerShell\6\pwsh.exe because it has a space. The answer is to create a symbolic link which is a file that contains a reference to another file (or directory): New-Item -ItemType SymbolicLink -Path C:\pwsh -Target […]
PowerShell Core v6.2.1
Posted by: richardsiddaway | May 21, 2019 Comments Off on PowerShell Core v6.2.1 |PowerShell Core v6.2.1 has been released – https://github.com/PowerShell/PowerShell/releases as has v6.1.4 The new versions are to primarily fix the Security Vulnerability CVE-2019-0733 – https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2019-0733 v6.2.1 also enables tab completion for functions
Windows Server 2019 updates with CIM
Posted by: richardsiddaway | May 19, 2019 Comments Off on Windows Server 2019 updates with CIM |Windows Server 2019 updates with CIM remain the same as all server versions post Windows Server 2016. This code will check for and install any updates. Micorosft Update or WSUS will be used depending on how your system is configured $au = Invoke-CimMethod -Namespace root/microsoft/windows/windowsupdate -ClassName MSFT_WUOperations -MethodName ScanForUpdates -Arguments @{SearchCriteria=”IsInstalled=0″} $au.Updates if ($au.Updates.Length […]
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