Tag Info

Hot answers tagged

7

Short answer: Not yet, but it's coming. Long answer: It's not actually part of Windows 10, but rather a new feature Microsoft is adding to PowerShell. Microsoft is working with and beginning to contribute to the OpenSSH project. This will effectively put an SSH server on Windows but you'll have to turn it on and have the latest version of PowerShell. ...


3

To do the same through powershell you can use Use with extreme caution, this script will delete hard drives! (Get-Disk).where({$_.BusType -like "ATA"}) | Clear-Disk -Confirm -Whatif -RemoveData -RemoveOEM (I've put -Confirm -Whatif to be removed, so people can't randomly delete their entire comp! - remove it to delete your entire comp) Obviously you ...


2

In batch, %~dpn0 returns the Drive, Path and Name of the currently executing script. To do the same in a PowerShell script you can use $MyInvocation.MyCommand.Definition. eg: $scriptPathAndName = $MyInvocation.MyCommand.Definition write-host $scriptPathAndName To get just the path to the script you could use: $scriptPath = split-path -parent ...


2

It’s really quite simple: Apply -Force. ;) Otherwise, hidden items (like the AppData folder) will be skipped. You need to use Get-ChildItem -Force -Recurse. And if you want to find all those space hogs, use a specialized tool like WinDirStat.


2

You could pop up some sort of message box. There are a few different ways to do that. Here's one easy way: $wshell = New-Object -ComObject Wscript.Shell $msg = "Default username is already taken. Continue?" $r = $wshell.Popup($msg, 0, "Warning", 4) if ($r -eq 6) { # Continue ... } For an explanation of the mysterious numbers 4 and 6, see Popup ...


2

Yes the "best" and "easiest" method of getting ESX information is with PowerShell and VMware vSphere PowerCLI. Basically PowerCLI adds cmdlts to PowerShell that allows you to query and retrieve information in your ESX farm. Check this link out for a getting started guide: Getting Started with VMware PowerCLI


2

How can I get process 'Elapsed Time' result? The following powershell command will display process elapsed time (in seconds): (Get-Process | ft Name,@{label="Elapsed Time";expression={[System.Math]::Round(((Get-Date)-$_.StartTime).TotalSeconds)}}) Source How to get total elapsed time of processes with PowerShell. It subtracts the process start time from ...


1

The RSAT tools for the release build of Windows 10 aren't out yet. It's expected sometime this month, alongside Tech Preview 3 of Server 2016. Once it's out, install and enable as you normally would. For now, you could always spin up a Windows 8 VM (using the included Hyper-V feature?) and import a remote PowerShell session from that. Something along the ...


1

Run for check (outside of cmder of course, from Win+R) ConEmu.exe -basic -cmd PowerShell.exe


1

The issue is that Cmder comes out of the box with the PowerShell tasks configured with the -NoProfile option. You can fix this through the gui (this shows I've already removed it...): Or you can do it directly in the ConEmu settings, found in cmder\config\ConEmu.xml:


1

For Format-Table you only have a few options. -AutoSize will make it look nicer and not as spread out and if you throw -Wrap on there as well, it can greatly help. Your other option is to do a custom table. An example is shown below $a = @{Expression={$_.Name};Label="Process Name";width=25}, ` @{Expression={$_.ID};Label="Process ID";width=15}, ` ...


1

You could alter your script such that the input should be y/yes or n/no. If it's not either of those, prompt again. This would eliminate accidentally confirming a change, but would require that you specifically press a key then enter to confirm or skip. Possibly better ways to do this, but that's my initial thought. As an aside, you can skip the $PROMPT = ...


1

Your question is quite broad, and I don't want to write a whole script, so I will just answer the main part of it. To replace "[ip]" in a file with "1.1.1.1": gc input_file.txt | % { $_ -replace '\[ip\]', '1.1.1.1' } | sc output_file.txt If you want to overwrite the original file, you need to put parentheses around the first statement so that it loads ...


1

I'm most fluent in Bash, but I'm sure you could do the same thing in Power Shell. I'm assuming that you are going to convert to .jpg format and store all the files in a ./output/ directory. My script would look like this: j=0; for i in `find . -type f \( -iname *.jpg -o -iname *.jpeg -o -iname *.png -o -iname *.gif -o -iname *.bmp \)` do j=$(($j+1)) ...


1

The current answers will only work for functions that have been created locally. You can, for example, see the definition of native functions like Get-EventLog. For a list of all the available functions, you can run: Get-ChildItem Function:: Any of these can be passed into ${function:myFn} or (Get-Command myFn).Definition If you want to peek at native ...


1

In recent version there seems to be a setting for this:


1

Try a positive lookbehind group instead of the non-capturing group: $pattern = [regex] '(?s)(?<=ExportSTL.+?global_scale = .+?default=)(.+?),' The lookbehind group will be required to match, but it won't consume any characters. The replacement string will be just '10.0'. A less exotic way would be to turn the non-capturing group into a normal group: ...


1

The best way to look inside a Word document from PowerShell would probably be to use COM automation. This tutorial looks good: Learn Powershell: Beginning with PowerShell and Word. You could then do a Google search for VBA macros that create a list of fonts, and translate that to PowerShell. Also see this question: List fonts used by a Word Document ...


1

The PrintManagement module includes these CmdLets and are Only available in Windows 8.1 and Server 2012R2 and later. These are not tied to the PowerShell version but the OS. https://technet.microsoft.com/en-us/%5Clibrary/Hh918357(v=WPS.630).aspx


1

The following will write the string out in the current Windows ANSI code page. This is probably what you will usually want to do to output single-byte encoded strings. echo zzz | Out-File -Encoding default test.txt You could also use ASCII: echo zzz | Out-File -Encoding ascii test.txt To output a byte array, do something like this: $myByteArray = ...


1

Using net use S: \\D-DWSQL01\Share\load Apparently allowed the schedule task to see the drive normally.


1

For Enter-PSSession cmdlet "-Credential" is not mandatory parameter. So if you don't specify credentials, your current credentials will be used.


1

To answer your second question, the following line will change the comment text to a Gray color: Set-PSReadlineOption -TokenKind Comment -ForegroundColor Gray You probably will want to execute this when PowerShell is launched, if so, then add this to your Microsoft.PowerShell_profile.ps1 file. And to answer your first question for a color scheme, you can ...


1

Try using ConEmu. You can set window transparency and background image transparency separately. It also has a lot of other useful features and is very customizable. ConEmu Website



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