Hot answers tagged

3

The article mentioned in jehad's comment explains that there are several places from which PowerShell can load a profile, which is what you want. You probably want the per-user one for the normal PowerShell console. The path at which PowerShell will check for that file is given in the $profile variable. You can create that file and its containing directory ...


3

RegEdit remembers the last key you were in by writing it to the registry on close of RegEdit. So if we set that registry key before opening RegEdit, it will be on the path we set. To do this, we'll need the name of the current PowerShell path (Get-Location), convert it to the format that Regedit saves it as (Convert-Path with "Computer\" prefixed to it), ...


3

Use del *.<extension> or one of it's aliases (like rm, if you are more used to bash). So it would be del *.avi to delete all files ending in .avi in the current working directory. Use del <directory>\*.<extension> to delete files in other directories.


3

You should separate paths with commas so they will be interpreted as a string array. mkdir folder-one, folder-one/sub-folder, folder-two Space is used to separate cmdlet parameters.


3

You can use the program VDesk to achieve this functionality. VDesk for Windows 10: launch programs on virtual desktops Vdesk is a portable program for Windows that adds the feature to Windows 10. It is a command line program but ships with an option to integrate its functionality in File Explorer. The main command looks like this: vdesk [n]...


2

here's a solution that also takes the screenshot. I'm using that in my scripts where I need to screenshot something. why automate only parts of the task, when you're also able to automate everything ;-) right? # Take Screenshot function - reads width and height from WMI, saves in outfile path function Take-Screenshot([string]$outfile) { [int]$...


2

WinRM already is set up to receive requests on this machine. WinRM already is set up for remote management on this machine. delete this winrm quickconfig out of your script. it wants to configure your WinRM service but it's already set up, so there's no need for this. WinRM lets you access Remote Computer via its Service, it's needed for e.g invoke-...


1

PowerShell commands no longer work The $env:psmodulepath seems to be correct: $env:psmodulepath C:\Users\myuserid\Documents\WindowsPowerShell\Modules;C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\;C:\windows\system32\WindowsPowerShell\v1.0\Modules";C:\Program Files\WindowsPowerShell\Modules You have a " (double quote) in the middle of ...


1

Just sending the keystrokes for alt+space, then X maximizes window. See below powershell script. Save as a .ps1. start microsoft-edge:http://google.com $wshell = New-Object -ComObject wscript.shell; $wshell.AppActivate('Google - Microsoft Edge') Sleep 2 $wshell.SendKeys('(%(" "))') Sleep 2 $wshell.SendKeys('(x)')


1

LastClosedWidth and LastClosedHeight may not be required if you're maximizing the window. The following binary values store the settings for maximized window. You may deploy the registry setting to PCs that use the same screen resolution. Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationFrame\...


1

$i=1 Get-ChildItem | ForEach { Rename-Item $_ -NewName ("filename" + $i + ".jpg") $i++ } Results: filename1.jpg filename2.jpg filename3.jpg ...


1

There is example here . I came across this little tip while exploring shell.application com object. It has other useful functions like undominimizeall, cascade windows, and many other explorer functions. $shell = New-Object -ComObject "Shell.Application" $shell.minimizeall() You can also undo minimize all windows by using below code. $shell = ...


1

What's going on is that the date/time stamps being returned from WMI are returned as Strings; $objItem.CreationDate.GetType().FullName returns System.String as it's type. This is why .ToString(), and other date formatting variations are failing when you try to format them as if they're a date. So you need to convert it from a String type into the ...


1

I assume you got your snippet from here: http://www.itninja.com/blog/view/manage-purge-local-windows-user-profiles You need to load the get-userprofile modules. Also, buddy uses ' to denote - in his code. So: get-content mydesktops.txt | get-userprofile | where {$_.LastUse -lt (Get-Date).AddDays(-90)} | remove-userprofile Script doesn't work for me if ...


1

Another solution would be to get the caption via WMI. I think it's closest to what you want. It can be used to check local and Remote machines. Local: (gwmi win32_operatingsystem).caption Example Output: PS C:\WINDOWS\system32> (gwmi win32_operatingsystem).caption Microsoft Windows 10 Pro Remote: Add the -computername parameter to gwmi Example ...


1

I'm wondering if there is an other solution to get the version of windows? Use the following command to retrieve the full Version String (which includes the Name, Version, and Service Pack number: [Environment]::OSVersion.VersionString Example output: PS F:\test> [Environment]::OSVersion.VersionString Microsoft Windows NT 6.1.7601 Service Pack 1 PS F:...


1

When executing a .cmd file a command prompt is opened within Powershell. All you have to is to exit the cmd by typing "exit". Thank you



Only top voted, non community-wiki answers of a minimum length are eligible