Questions tagged [powershell]

Windows PowerShell is a command line shell and scripting language for Windows that supersedes the CMD.exe shell and batch language. PowerShell is also an automation engine for Windows that provides functionality similar to Windows Script Host and VBScript.

Filter by
Sorted by
Tagged with
2 votes
1 answer
12k views

Powershell string concatenation of expressions

I'm using a ternary expression as shown in this example: $a = 1 $x = if ($a -eq 1) { "one" } else {"not one" } $t = "The answer is: " + $x write-host $t This works as I would expect. What I would ...
Chris Davies's user avatar
  • 3,833
2 votes
1 answer
1k views

PowerShell 5.0 Get-Help -ShowWindow doesn't display detailed parameters description

In PowerShell 3.0 and 4.0 when running: Get-Help Get-Service -ShowWindow it displays new window with full description of GetService command (with detailed parameters description). When running the ...
torpederos's user avatar
2 votes
1 answer
5k views

PowerShell get TotalPhysicalMemory (RAM) without decimals

I'm writing a powershell script to inventory some info about computers (CPU, RAM, HDD, etc...). Everything is working quite well, but I'm stuck at getting the right output for the amount of RAM. Here ...
Merwyn's user avatar
  • 68
2 votes
1 answer
35k views

Windows Activation Powershell Script

I'm looking for a method to automate activation Windows 7 machines through PowerShell. We get approximately 50 computers a month and it's slowly increasing, so manual activation is no longer possible ...
AceHigh's user avatar
  • 23
2 votes
2 answers
4k views

How do I open a command prompt as a regular user (not an adminstrator)?

I'm trying to fire up a regular command prompt to test the limitations of certain commands. However, whenever I open the Command Prompt from the start menu, it automatically runs as Administrator. If ...
user avatar
2 votes
1 answer
7k views

Powershell script to open a number of files located inside subdirectories

How does one open (say, using notepad.exe) multiple files ending in _dc.txt, each one of which is located in a number of subdirectories of C:\Data\Test? My script below gets stuck on -Recurse, with ...
val's user avatar
  • 123
2 votes
2 answers
30k views

Listing Mapped Drives and Username Powershell Script

It's been a little while since I've touched PowerShell so struggling to get this working as I expect. $computerlist = Get-Content H:\MappedDrive\ListOfMachines.txt ForEach ($computer in $...
CharlesH's user avatar
  • 2,193
2 votes
1 answer
2k views

Powershell LastWriteTime is incorrect

I am running the following script to create directories based on the first 9 characters in the filenames in the directory and then moving te files into these directories based on their filenames. dir ...
nate's user avatar
  • 21
2 votes
1 answer
270 views

Use PowerShell to interpret registry values

Consider the following key, as an example HKEY_CLASSES_ROOT\txtfile\shell\open\command and its (Default) value %SystemRoot%\system32\NOTEPAD.EXE %1 This value determines what will happen when you ...
Zombo's user avatar
  • 1
2 votes
1 answer
21k views

PowerShell: create a new Active Directory user with password as a secure string

Having some trouble creating a command to create a new user in PowerShell, the code I'm using is: PS C:\Users\Nicky> New-ADUser -Name johnd -GivenName John -Surname Doe -DisplayName John Doe $...
nkern0's user avatar
  • 21
2 votes
1 answer
3k views

Command Line Parameters in Powershell

I am using a program called sonar-runner that you execute from the commandline, and you can pass optional parameters. For example in the normal windows commandline tool a call may look something like: ...
Jacob Schoen's user avatar
2 votes
1 answer
5k views

PowerShell periodically hangs after any command

My PowerShell shell sometimes hangs after any command - such as ls. Also, after I force close the window, when I open another shell window, it shows the following error: Windows PowerShell Copyright (...
joon's user avatar
  • 589
2 votes
6 answers
14k views

Running powershell script through Windows Task Scheduler

I'm trying to run a simple PS1 powershell script from the Task Scheduler. The task's Actions settings are Program: powershell and Add arguments: -executionpolicy bypass -file C:\Users\Robin\Documents\...
geotheory's user avatar
  • 1,089
2 votes
1 answer
5k views

PowerShell touch all files newer than

I have found the following question on ServerFault: Windows recursive touch command Which partially answers my question with this answer: Windows recursive touch command However, I would like to ...
atwright147's user avatar
2 votes
2 answers
3k views

Get another local users home directory

I am trying to automate the copying of profile data from one user account to another. This other user account is being created in a PowerShell script from an Administrator account. I am copying over ...
Simon Campbell's user avatar
2 votes
1 answer
1k views

Using PowerShell to replace individual bytes in a document

We're in the process of converting an HTML help system to a SharePoint document library. We have about 3000 individual HTML documents that we're converting to Word. About 20% of the documents include ...
dwwilson66's user avatar
  • 1,749
2 votes
1 answer
2k views

Windows 8 power-shell "update-help" is failing. Does anyone know how to fix it?

Windows 8 includes PowerShell 3 out of the box, but not the help. To get the help you run PowerShell as administrator and type "update-help". I get this error: > update-help update-help : Failed ...
Warren  P's user avatar
  • 2,950
2 votes
3 answers
466 views

In Power SHell set alias cp to cp -v

I have cp for power shell. But I want to use cp in verbose mode without writing -v. So cp should be aliased to "cp -v" command. How to alias cp to "cp -v" in power shell?
Narek's user avatar
  • 1,421
2 votes
4 answers
5k views

Querying against Active Directory

I'm the "script guy" at my work, which is a blessing and a curse... I've been tasked with generating a script of: Can you create a script to pull all users that have a proxy address that is not ...
WernerCD's user avatar
  • 4,333
2 votes
1 answer
7k views

problem powershell cant access to a network share

I use PowerShell to check if any ports are open on my computers. I have eight Windows Server 2008 R2 machines and run the following script: $localhost = get-content env:computername foreach($port in ...
alex's user avatar
  • 131
2 votes
2 answers
3k views

Automatically open a PowerShell session on Hyper-V Server 2008 R2 or Windows Server 2008 R2 Core?

I have a virtual server running with Hyper-v r2 sp1 (standalone product). I imagine it applies also to W2K8 Core install. When I connect to the remote desktop, both sconfig.cmd and cmd.exe are ...
Steve B's user avatar
  • 2,222
2 votes
2 answers
4k views

How do I create a PowerShell alias (or function) that contains an option?

I'm learning PowerShell, so I'm doing stuff like this a lot: Get-Command | Out-String -Stream | ss child (ss is an alias for select-string). I'm getting tired of typing Out-string -Stream all the ...
jonathan's user avatar
2 votes
2 answers
9k views

Running a powershell script using a batch file (.bat)

Currently this is my path for launching VMware vSphere PowerCLI command prompt. I wish to run my sample.ps1 script automatically using a batch file. How can I incoporate sample.ps1 into this path and ...
user448402's user avatar
2 votes
3 answers
932 views

PowerShell - environment vars - differentiating between user and system vars

How can I display environment variables in PowerShell, and be able to distinguish between which ones are "user" vars and which ones are "system" vars?
mr_magoo's user avatar
2 votes
1 answer
2k views

How can I easily place multiple powershell windows on login?

I like to have a 2x2 grid of powershell windows open on my alternate monitor, but I'd prefer not to have to open and resize each one by hand. I can set the window size (through (Get-Host).UI.RawUI....
moswald's user avatar
  • 250
2 votes
1 answer
707 views

In Powershell on Windows7, how do I automatically set aliases (or run scripts) when powershell loads?

I have created a powershell cmdlet and assigned it to an Alias. How do I do this automatically every time powershell launches? (i.e. so I don't have to re-assign the alias every time)
willem's user avatar
  • 488
2 votes
2 answers
159 views

Count matches from robocopy output in powershell

I have the following robocopy command line: robocopy $drv "B:\Blending Produções - Backup\Blending Produções - Tyrone Hirt - BC" /e /NJH /NDL /NC /BYTES /MT:4 /l /xd /A-:SH $IgnorarPastas /...
Tyrone Hirt's user avatar
2 votes
1 answer
163 views

Switching 'net' Command Output Language in Windows 11

Main Question (command language output) How can I convert the output or account/group names to English? Additional bonus related questions Why are there "aliases" mentioned in the net ...
not2qubit's user avatar
  • 2,295
2 votes
1 answer
702 views

Create a Symbolic Link from Windows to WSL with a Local Admin Account

I am trying to share a config file between windows and wsl/linux. The file is in wsl/linux and I want to link to it from windows. This is the command I am trying with a local admin account: New-Item -...
mrt181's user avatar
  • 915
2 votes
1 answer
339 views

I accidentally activated this history search feature in powershell core. What is it called?

I have a rather unusual request - I accidentally activated this feature with my laptop keyboard: It shows all previous commands that match my command prompt. It is very useful, but it appears to be ...
Tim's user avatar
  • 141
2 votes
3 answers
268 views

ssh_config matching rules

I am trying to set up connection to [email protected] via powershell terminal (with config located in .ssh\config) without proxy, however, I want to keep being able to connect to ...
Peter's user avatar
  • 23
2 votes
1 answer
761 views

Obtaining RAM usage per logon session in PowerShell

I want to get the memory used per session through a PowerShell function. I am only interested in disconnected sessions. In the task manager, I can see the memory used per sessionID: I tried to obtain ...
rinkert's user avatar
  • 123
2 votes
1 answer
2k views

List of CDN URL's used for Winget

I am currently trying to roll Microsoft Store app (new) via Intune, but it looks like some of the CDN URLs are being blocked by our web filtering software (Forcepoint) I would like to know where ...
Shaky_Milkshake's user avatar
2 votes
2 answers
11k views

Remove all pinned apps in start menu using power shell

Im making a script that cleans a fresh install of windows 11 to my liking. Does anybody know of a way to unpin all apps in start menu using PowerShell? I have found scripts but those scripts are name ...
Jack's user avatar
  • 161
2 votes
1 answer
373 views

Why doesn't the login screen show a created New-LocalUser or the Administrator account?

Login is with a pin code and right clicking on cmd allows running in an elevated mode as Administrator so that new accounts can be created: adding a user: PS C:\Windows\System32> PS C:\Windows\...
Nicholas Saunders's user avatar
2 votes
1 answer
3k views

Capture batch output and save it in TXT File as log

I'm running powershell script with batch file. My requirement is:- display the output in batch cmd and at the same time save output in TXT file. Note, as of now output getting saved in txt file but ...
Suraj Kumar's user avatar
2 votes
1 answer
2k views

How to deploy a powershell-installer via the intune-portal?

I've got the powershell install script for the windows command-liner installer Scoop which is called: install.ps1. After downloading the script with irm get.scoop.sh -outfile 'install.ps1' I want to ...
hmaier's user avatar
  • 73
2 votes
2 answers
554 views

Call current date&time into dynamic variable in Powershell

I need to create some logs that contain the current time I don't want to repeatedly call the Get-Date cmdlet How can I simply set a dynamic variable? I've tried this: $CurrentTime=(Get-Date -Format &...
Cheloveshka's user avatar
2 votes
1 answer
21k views

What is the correct usage of the scp command in Powershell?

I am trying to retrieve some data from a remote directory (with an IP address) using the scp command in Windows Powershell. However, when I enter the command scp -r root@<remote IP>:<remote ...
KSH's user avatar
  • 23
2 votes
1 answer
222 views

What does the "usage" mean in the "Get-PhysicalDisk" results?

The document for Get-PhysicalDisk simply listed the possible options for the Usage parameter. Does anyone know how those values are defined?
David S.'s user avatar
  • 936
2 votes
1 answer
2k views

PowerShell : Watch a folder and when file created, send it by mail

I would like to create a script watching a specific folder in my computer, and if a new file is created, send this file by email. What I found : $action = { $WatchFolder = "C:\Users\..." $To ...
Maxime's user avatar
  • 41
2 votes
1 answer
89 views

how to get the pajama effect with New-Object -com Excel.Application

Does anyone know how to get this effect? Or is there a specific function for it?
zeros's user avatar
  • 271
2 votes
1 answer
3k views

PowerShell, how to disable Xbox Game Bar?

I really need to disable the Xbox Game Bar with PowerShell. There are many articles on how to delete/uninstall the Xbox Game Bar but that does not work for me as I need this inside Windows Sandbox (...
YorSubs's user avatar
  • 909
2 votes
2 answers
1k views

PowerShell, add the Recycle Bin to Quick access

I would very much like to add the "Recycle Bin" to the "Quick access" area of File Explorer using PowerShell (as this is a standard thing that I like to have on all new systems). ...
YorSubs's user avatar
  • 909
2 votes
1 answer
3k views

position the form to the far right Windows.Forms

code: Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing [System.Windows.Forms.Application]::EnableVisualStyles() $form = New-Object System.Windows.Forms.Form $form....
zeros's user avatar
  • 271
2 votes
2 answers
8k views

Is it possible to log powershell scripts which executed on my computer?

Title says it all. I already turned on logging via regedit but I want something more stable. I would like to see every commands which executed on powershell to be in my event log just like Sysmon.
Cute Bear's user avatar
  • 141
2 votes
1 answer
43 views

Cannot catch output of programme. No one of streams redirection works

I would like to save the result of analysis of a number of nested sampling log files. I analyse it the next way: applauncher NSLogAnalyser -noposterior -N 76 -log .\...
Vovin's user avatar
  • 135
2 votes
2 answers
6k views

PowerShell How to Get File Owner/Author?

Below script retrieve specific file types from the I: drive and outputting specific file properties to a delimited CSV file. How to return file owner and authors? Any help is very much appreciated. ...
panes-rubrics.0l_icloud.com's user avatar
2 votes
1 answer
2k views

Windows 11 pro - using task scheduler to send an email on shutdown?

How can I configure Windows 11 pro to send an email immediately prior to shutdown? I've written a simple powershell script to send an email (this works fine) but I'm having trouble persuading the task ...
ConanTheGerbil's user avatar
2 votes
1 answer
3k views

List all user accounts with an active presence on the local device

I need a way in PowerShell (ideally PS2.0+) to list all user accounts on a local system where a user has a local presence, but where users may not be local users per se. That is to say that the device ...
seagull's user avatar
  • 5,546

1
26 27
28
29 30
117