Set

choubertsprojects

The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

Set is a blockchain-powered social media platform that puts user privacy and data ownership at the center of its design. The goal: Create an entirely decentralized network, so all interactions on Set are handled by peers in the community, not centralized servers. With this model comes more accountability too; users who violate terms of service are automatically banned from the platform to protect their own interests.

The “set online game” is a command-line tool that allows users to set their current operating system’s network connectivity status. It also has the ability to change your computer’s name and boot device.

Set

Set-Content is one of those indispensable PowerShell cmdlets for me. Before we could use PowerShell to write to a file, we had to utilize VBscript. I recall constantly attempting to recall the kind of object I required and the function name. Was it FileSystemObject, FileObject, or something else entirely? It was a hassle! I’d usually forget to provide True as the second parameter, even when I remembered the function name was CreateTextFile().

Here’s an illustration of the monster I’m referring about.

Set the property objFSO=CreateObject to true (“Scripting.FileSystemObject”) outFile=”c:file.txt” Set the objFile variable to objFSO. objFile CreateTextFile(outFile,True) objFile should contain the string “test string.” Close

Compare and contrast the VBScript with the following PowerShell:

Set-Content -Path ‘C:file.txt’ -Value ‘test string’ Set-Content -Path ‘C:file.txt’ Set-Content -Path ‘C:file.tx

Which one is your favorite? I’ll go the PowerShell route! Set-content is a single cmdlet in PowerShell that does it everything. This cmdlet makes it much easier to write to a file using PowerShell. This is a built-in PowerShell cmdlet that only has one purpose: to write to a file.

It may include a few options to alter up the behavior a little, but it’s mostly concerned with writing to a file. Although they are similar, they should not be confused with Add-Content. Set-Content overwrites a file completely, while Add-Content adds to it. When I originally began out, I had to learn that lesson the hard way many times!

Making a File/Replacing a File

Set-Content is a straightforward cmdlet. A nice example may be seen below. This example demonstrates how Set-Content may build a file from scratch or replace all of the contents of a pre-existing file.

PS> Test-Path -Path C:test.txt False PS> Set-Content -Path C:test.txt -Value ‘foo’ PS> Get-Content -Path C:test.txt foo PS> Set-Content -Path C:test.txt -Value ‘bar’ PS> Get-Content -Path C:test.txt bar

Save the output to a file

One cmdlet that can Save the output to a file is Out-File, but Set-Content can perform the same task albeit a little differently.

You could want to extract certain text from one text file and export lines to a different file. You may do this by using Get-Content and Set-Content. Maybe I have a text file with one line for each server’s status. I’d want to read the status of each server and save it to a file. It’s feasible using Get-Content to read the file and Set-Content to write to the file.

PS> Get-Content -Path C:test.txt SRV1 Status: Up SRV2 Status: Down SRV3 Status: Up PS> Get-Content -Path C:test.txt | ForEach-Object { >>> $srvName = $_.Split(‘ ‘)[0] >>> Set-Content -Path “C:$srvName.txt” -Value $_ } PS> Get-ChildItem -Filter ‘SRV*’ Directory: C: Mode LastWriteTime Length Name —- ————- —— —- -a—- 10/29/2017 12:38 PM 17 SRV1.txt -a—- 10/29/2017 12:38 PM 19 SRv2.txt -a—- 10/29/2017 12:38 PM 17 SRV3.txt PS> Get-ChildItem -Filter ‘SRV*’ | Get-Content SRV1 Status: Up SRV2 Status: Down SRV3 Status: Up

Set-Content is one of those essential cmdlets that is often used. It’s not flashy, but it always works, and it’s a useful tool to have in your PowerShell toolbox.

Check out the Set-Content Microsoft docs for a complete analysis.

The “set synonym” command allows you to set a word as a synonym for another. The “synonym” is also used to change the order of words in a sentence.

Related Tags

  • set game
  • daily set
  • set card game
  • set card game online
  • set with friends

Table of Content