Newest powershell Questions

Q&A for system and network administrators

Empty network configuration in Azure (networkconfig.xml)

I've recently created an Azure trial account, and we've got it set up and connected to our on-prem network (via IPSec tunnel over ASA). I can communicate with a Linux VM I threw up in Azure from my ...

Configure RRAS LAN Routing without the wizard but with powershell

Usually we use the setup wizard to congure "LAN Routing": https://i.stack.imgur.com/7cfoT.png https://i.stack.imgur.com/YJwd1.png I want to do the same but whit powershell, but I can't find how. ...

'Get-WBJob' and 'Get-WBSummary' unrecognised commands

I am using a script that is set to run every morning read if teh last backup failed or completed and then puts it into a html page. This works fine on all of our 2012/2012R2 servers using the Get-...

Set GPO computer configuration with Powershell

I want to set local users and groups in computer configuration of my GPO with Powershell. Aim is to create and update the following structure. Currently I'm using Powershell Version 4 on a ...

PowerShell Script can't set location to 8.3 filename temp location

I am having troubles getting the Windows Update Log on Server 2016. As documented here Server 2016 now logs Windows update logs differently and to view the logs you need to run a Powershell command ...

Exchange EWS Managed API access permissions different from other permissions?

I'm trying to get an understanding on how permissions in Exchange and handled and I'm a bit confused. Maybe someone could help me understand the difference? I do have an account that is able to run ...

String manipulation in the pipeline

I am looking at pulling out a portion of a property from within the pipeline, but I cannot seem to get it. If I was using ISE or a ps1 file, I could just manipulate as needed and output, but I need ...

Getting User group members using Powershell

I got a script Invoke-Command {net localgroup administrators} which only work in server 2012 & not in server 2008R2, getting error as mentioned below, even though "WinRM already is set up to ...

Understanding exactly why the timestamp was not affected of ad objects

I made a script that takes data from an HR database and populates correlating attributes in AD e.g department, title, manager, location. Since people change titles, departements and/or locations on ...

MSSQL proxy system permissions required to run PowerShell steps

I started to ask this on StackExchange DBA but decided it was probably going to be more of a Windows Server security type of question. SQL Server 2016 SP1+CU on Server 2012 R2. I'm trying to run a ...

Enable-PSRemoting or Set-WSManQuickConfig?

I'm getting pumped up for DSC and I want to cover my bases. I see that Enable-PSRemoting actually runs Set-WSManQuickConfig according to help documentation, I guess my main question is, what is the ...

Manage mailbox without Exchange Management Tool

In my previous job I have created a few powershell scripts that handle mailboxes using Exchange Management Tools and the cmdlet installed. Now I have a similar environment but I can't install the ...

“Permission Denied” creating a new domain-based Dfs root as non-Administrator

I have been tasked to delegate a number of everyday tasks in our domain to a group of technicians which does not have Domain Admins membership. One of these tasks is the creation of new domain-based ...

Exporting and Importing Printer Settings using PowerShell

I am looking for a solution to export settings which were made on a specific printer which uses for example a "CAB A3 300DPI" Driver and import them afterwards on a diffrent device, which is using the ...

WinRM failing when attempted from Win10, but not from WSE2016

I'm unable to PSRemote to my Hyper-V host, nor can I connect to it using Hyper-V Manager. This occurs from a client VM, but not the server VM. I can PSRemote and connect without problem from the ...

How to get UserID of Mail-User via powershell

Using Powershell, how can I get the UserID of an account if I don't know which domain it is in? For example, I have a Mail-User account called b.newhart and I can fetch information using that as the -...

Ways to extract files information for large data

I am trying to recursively extract some file information in my file server. I was able to run the commands below at my own laptop. When I run them on my file server, which is going thru 4TB of data, ...

Powershell Set/Get-GPPermission missing from Group Policy on Windows 10

Recently updated from windows 7 enterprise to windows 10 enterprise and went to run a script that has a call to Get-GPPermision and it errored out as missing that command. Edit: Set-GPPermission is ...

Query Powershell Error Object Time Occured

Powershell error objects contain a lot of data but I can't seem to track down the time of occurrence for a given error. Using $Error[0] | fl -f retrieves a lot of information but none that appears to ...

Why can't I set the default reply font in Outlook? [migrated]

I am trying to set the default fonts in Outlook programmatically via registry manipulation. I'm using Powershell (but it's academic, as the code is "working" so I could be using C# or something ...

Only allow remote command with credentials

I have server A and a server B in the same domain (Windows Server 2012 R2): PS C:\Deployment> $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 4 0 -...

regex excluding lines with x number of \'s

I am sure this has been asked and solved before but I am stuck on this simple regex expression. I am using powershell and .net for the regex. Let's say I have a file which contains these lines: C:\...

Getting the backup directory of an SQL Server 2014 via Powershell

On an SQL Server 2012 machine I use the following Powershell script to get the configured backup directory: $srv = New-Object Microsoft.SqlServer.Management.Smo.Server("localhost") $BackupDirectory = ...

Get-AutomationPSCredential fails intermittently in Azure Automation

Every so often, we find an Azure Automation Runbook fails with the following error: Get-AutomationPSCredential : The term 'Get-AutomationPSCredential' is not recognized as the name of a cmdlet, ...

Get local User group members - Powershell

$Output = 'C:\temp\Result.txt' $Servers = Get-Content 'C:\temp\ServerNames.txt' $ScriptBlock = { $Groups = Get-WmiObject Win32_GroupUser -ComputerName $Servers $LocalAdmins = $Groups | Where ...

Enable-PSRemoting Error

I manage a network of over 100 2008R2 Servers. There is no domain on the network for various reasons. I am running Enable-PSRemoting -Force on all the servers. Some of them are running just fine, ...

Powershell script to automate the windows update along with optional updates

I was using below powershell script to update windows https://gallery.technet.microsoft.com/scriptcenter/Execute-Windows-Update-fc6acb16#content It works fine for Windows updates. But it does not ...

Powershell gives different results in Exchange, than in Office 365

I run the following commands to return all mailboxes that have a forwarding address configured: Get-Mailbox -ResultSize Unlimited | Where {$_.ForwardingAddress -ne $Null} I then extract the email ...

Any other way how to access Previous Versions (VSS Shadow Copy) from terminal not using WMI/CIM?

I would like to list paths of VSS Previous Versions from terminal (CMD/Powershell). There is PowerShell way how to manage VSS via WMI/CIM: Get-CimInstance -ClassName Win32_ShadowCopy Get-WmiObject -...

Why can't I Set-Location (cd) to the object returned by Get-ChildItem? (aka ls, dir)

ls "d:\" "yasuo500" -recurse -directory This command finds the folder 'yasuo500' in d:\media\documents, I want to use 'cd' to get into that directory, but how? i tried this: $path1 = ls "d:\" "...

import list of pcs using import-Csv and change attribute using powershell script

Im trying to write a powershell script to change attribute called "comment" in a list of pcs using csv and import-Csv. Here is my script $computers=Import-Csv -Path "C:\sds.csv" foreach ($...

WEF collect Windows Defender logs from clients on Windows Server 2012 R2

I'm trying to set up Windows Event Forwarding on a Windows 2012 R2 collector server. I was looking to collect events from Windows Defender, which comes by default on Windows 7 and 8 clients. I know ...

Has anyone solved the double-hop issue with Ansible and Windows clients?

My situation: I have an Ansible server, a Tower server, a Windows file server, and a Windows client. Through Ansible, I want to tell the Windows client to copy some files from the Windows file server. ...

Remove a user from ACL completely using PowerShell

I wish to remove a user from folder permissions using PowerShell. I have found plenty of examples on how to remove the user permissions but I actually want to remove the user entirely. The equivalent ...

Set Skype for Business PIN for all users

I know that the PowerShell command to set a single user's Skype for Business PIN is this: Set-CsClientPin -Identity "User Name" -Pin 123456 This page seems to help: https://technet.microsoft.com/en-...

Need help creating a report from powershell

I have a list of computer names and I need a report of their OU, their mangedby attribute and their name. I have created a stack with each setting I want but they are not lining up. For 650 computers ...

How can Run programs after autorisation on anyone PC for AD user?

I have 20 Lenovo Q190, and 2 users in my network (based on Windows Server 2012R2) work with specific software can run only they. After successful authorization, a specialized software for working ...

How do I add the Windows GUI to Windows 2016 Server Core?

We just got our dedicated server from Rackspace. It was loaded with W2008 on it. I decided to put the most recent OS on it so I wouldn't have to upgrade it later. Apparently during the installation, I ...

Netsh trace vs PEF trace cmdlets vs NetEvent cmdlets

I am playing with capturing my network traffic and came across two different MS commandline tools that allow doing this: a well-known netsh tool, recently equipped with powerful capture switch a ...

How to determine if remote wipe succeeded?

Environment: Office 365 online. Exchange v15.1.933.16. One of our global administrators performed a remote wipe on a mobile device via the exchange admin centre, and then 'deleted' the device from ...

Storage Spaces Get-VirtualDisk -FriendlyName vDisk | Get-PhysicalDisk

I am using Server 2016 storage spaces. I have created a virtual disk in a storage pool via powershell (FriendlyName "vDisk") I have also created another virtual disk via the gui (FriendlyName "test")....

Exchange Management Shell does not connect to localhost but connects to a neighboring server

A pretty much default Exchange 2013 on-premises installation, with two CAS and two MBX servers, all of them running Windows Server 2012R2, Exchange updated to CU13. Using the default Exchange ...

Move-ADObject Access is Denied when using limited access credentials

I have OU folders in the root of my AD that look similar to this: AA --AB BA All of these OU's contain computer accounts. I have a computer in BA that I want to move to AB. I am using credentials ...

How to reset Warning and Critical monitors using a script

I'm trying to create a ps script to reset all warning and critical monitors every night. If I run any of these instruction (one at time) works fine, (Obviously the foreach instruction is looking for ...

New-ADUser with Splatting errors

I am getting an error when trying to run the following snippet. $Users = Import-Csv -Path $Path foreach ($User in $Users) { $Domain = "Domain.lan" $DefaultPassword = '...

Active Directory - Account exists but cannot find it to remove it

I'm trying to add an AD Managed Service Account and my first attempt was as follows: New-ADServiceAccount -DNSHostName VM-Backup-Service -Name "VM Backup" -samAccountName VM_Backup -Path "OU=...

Powershell read from CSV set variables

I was hoping I could get some guidance. I have a csv file with two columns "Path" and "Owner" I've created the belkow script and it can read from trhe CSV file, but when I attempt to assign the ...

Win32_LogonSessions returns older sessions

I'm trying to identify logged sessions using a WMI query using PowerShell with: $logon_sess = @(gwmi win32_logonsession -ComputerName $computername) But I see that this command is also reporting ...

DSC Environment Resource no longer working after WMF5.1 - not detecting PATH values?

I have a number of Partial DSC scripts that use the Environment Resource to set a Path value. I have two scripts that does this and after upgrading from WMF5.0 to WMF5.1, I am getting the following ...

Why is HyperV Checkpoint-VM parameter SnapshotName ignored when Powershell remoting?

Having this code in powershell: $Servers = "computer.domain.com" # Open Session $Session = New-PSSession -ComputerName $Servers # Create Daily Checkpoints. Invoke-Command -Session $Session -...
Translating... 0%