www.fgks.org   »   [go: up one dir, main page]

PowerShell Community

A place for the community to learn PowerShell and share insights

Borrowing a built-in PowerShell command to create a temporary folder
Borrowing a built-in PowerShell command to create a temporary folder
Q: Hey I have a question for you. It seems silly and I know I could probably put something together with Get-Random. But can you think of another way to create a temporary folder with a random name in PowerShell? Ideally, I'd like it to be in a user's own "Temporary Folder" is possible. A: We sure can! If Doctor Scripto was sitting here ...
Is a User a Local Administrator?
Is a User a Local Administrator?
Q: Some of the things we do in our logon scripts require the user to be a local administrator. How can the script tell if the user is a local administrator or not, using PowerShell 7. A: Easy using PowerShell 7 and the LocalAccounts module Local Users and Groups The simple answer is of course, easily. And since you ask, with PowerShell 7! ...
Testing the connection to computers in the Active Directory
Testing the connection to computers in the Active Directory
Q: As an administrator, I often have to do a lot of reporting on the servers in my domain. Is there a simple way to test the connection to every server in my domain or every server or client host in a specific OU? A: Of course you can do this with PowerShell! You can use the Active Directory cmdlets and Test-Connection, although it is not as ...
Can I Enable the Caps Lock Key?
Can I Enable the Caps Lock Key?
Q: I have a script where users enter some information. This information needs to be entered in all capital letters, so my instructions say, “Please make sure the Caps Lock key is on before entering the information.” They don’t always do that, however. Is there a way to turn the Caps Lock key on and off using a script? A: I don't know ...
Determine if a folder exists
Determine if a folder exists
Q: Is there any way to determine whether or not a specific folder exists on a computer? A: There are loads of ways you can do this. The Test-Path Cmdlet The easiest way to do this is to use the Test-Path cmdlet. It looks for a given path and returns True if it exists, otherwise it returns False. You could evaluate the result of the Test-Path...
Reading a text file bottom up
Reading a text file bottom up
Q: I have a log file in which new data is appended to the end of the file. That means the most recent entries are at the end of the file. I’d like to be able to read the file starting with the last line and then ending with the first line, but I can’t figure out how to do that. A: There are loads of ways you can do this. A simple way is ...
Getting Yesterday’s Date
Getting Yesterday’s Date
Q: How can I get yesterday's date? A: You can use a combination of the Get-Date cmdlet and .NET Time/Date methods. First, let's look at dates in PowerShell and .NET Then we can look at how to calculate yesterday and use that in your scripts. Dates in PowerShell Let's start by looking at how you can deal with dates and times. As you ...