top of page
Search
Writer's pictureJose Rodriguez

PowerShell Command Get-Content a Quickie

This a brief description on how to use the Get-Content command. This is useful in retrieving data from a file without opening the file. It can be used in creating variables out of the file data instead of hard coding it. It stands to reason that you could use this feature not only in PowerShell but within a function in either javascript or python. I haven't gotten that far but there is a possibility in the future.




Converting the data of a file to a Variable Flaws and All

Here is where I get cocky. The premise is simple, make a variable using all of the data in a target file. Then use the Get-Content command to shoe the file content as the variable data. Long story short only it didn't work out that way. I succeeded in the first part. Getting it the show the file contents didn't workout the way I hoped. Amidst the abundance of red text I did get confirmation that the file data was in the variable. It just says it does not exist.


Get-Content : Cannot find path 'C:\Users\Pepe\Desktop\TestBed\ x=56 y=380 z=23' because it does not exist.


This is the prologue to another episode of "Back to the Drawing Board.".




Exploring PowerShell Get Commands and other stuff


In the process of building new tools in PowerShell to make my life easier at work. I come across some commands that by themselves don't seem like very much. With a little creativity and effort these are the building blocks to more sophisticated (complicated) projects. That is where I am going in this video. I am going over somethings that aren't going to rock your world, but have the potential to inspire you to unlock different ways to finish a single or multiple tasks. Below is a list of the commands reviewed.


Commands Reviewed:

* Get-Date

* Get-Date | Format-List

* Get-Random

* Get-Date

* Get-TimeZone

* Set-TimeZone

* Stop-Process -Name "WordPad"

* Get-Host

* Get-Command *process*

* Test-NetConnection -ComputerName www.google.com




1 view0 comments

Kommentarer


bottom of page