Skip to content

Commit

Permalink
chore: Regenerate tip json file
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlydog committed Jul 19, 2024
1 parent 8103c80 commit 29a54f6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/tiPS/PowerShellTips.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,19 @@
"ExpiryDate": "9999-12-31T23:59:59.9999999",
"Author": "Daniel Schroeder (deadlydog)"
},
{
"CreatedDate": "2024-07-18T00:00:00",
"Title": "Easily expand environment variables in a string",
"TipText": "You can use the `[System.Environment]::ExpandEnvironmentVariables()` method to easily expand environment variables in a string. Simply wrap the environment variable name in % characters. You can even expand multiple environment variables in a single string.",
"Example": "# Expand a single environment variable and store it in a variable.\r\n$tempDirectoryPath = [System.Environment]::ExpandEnvironmentVariables('%TEMP%')\r\n\r\n# Alternative is to use the $Env: syntax to retrieve a single environment variable.\r\n$tempDirectoryPath = $Env:TEMP\r\n\r\n# Expand multiple environment variables in a string.\r\n[System.Environment]::ExpandEnvironmentVariables('My system drive is %SystemDrive% and my system root is %SystemRoot%')",
"Urls": [
"https://learn.microsoft.com/en-us/dotnet/api/system.environment.expandenvironmentvariables",
"https://x.com/adbertram/status/1777421663581130856"
],
"Category": 3,
"ExpiryDate": "9999-12-31T23:59:59.9999999",
"Author": "Daniel Schroeder (deadlydog)"
},
{
"CreatedDate": "2024-07-18T00:00:00",
"Title": "Stay up-to-date with the latest PowerShell events",
Expand All @@ -679,7 +692,7 @@
"CreatedDate": "2024-07-18T00:00:00",
"Title": "Use the -is operator to check a variable's type",
"TipText": "PowerShell provides the -is and -isnot operators to check if a variable is of a specific type. This is useful when you need to ensure that a variable is of a certain type before performing an operation on it. It is also more reliable and performant than using the GetType() method.",
"Example": "(get-date) -is [DateTime] # Result is True\r\n(get-date) -isnot [DateTime] # Result is False\r\n\r\n$number = 42\r\n$number -is [int] # Result is True\r\n$number -is [string] # Result is False\r\n\r\n# Can also use the -is operator with the type name as a string\r\n$number -is 'int' # Result is True\r\n\r\nif ($number -is [int]) {\r\n Write-Host \"$number is an integer\"\r\n}\r\n\r\n# Don't do this. It's less reliable and performant than using the -is operator.\r\nif ($number.GetType().Name -eq 'Int32') {\r\n Write-Host \"$number is an integer\"\r\n}",
"Example": "(get-date) -is [DateTime] # Result is True\r\n(get-date) -isnot [DateTime] # Result is False\r\n\r\n$number = 42\r\n$number -is [int] # Result is True\r\n$number -is [string] # Result is False\r\n\r\n# Can also use the -is operator with the type name as a string.\r\n$number -is 'int' # Result is True\r\n\r\nif ($number -is [int]) {\r\n Write-Host \"$number is an integer\"\r\n}\r\n\r\n# Don't do this. It's less reliable and performant than using the -is operator.\r\nif ($number.GetType().Name -eq 'Int32') {\r\n Write-Host \"$number is an integer\"\r\n}",
"Urls": [
"https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_type_operators",
"https://x.com/adbertram/status/1779473980631433681"
Expand Down

0 comments on commit 29a54f6

Please sign in to comment.