Found 2039 Articles for Microsoft Technologies

How to change files and folders attributes using PowerShell?

Chirag Nagrekar
Updated on 16-Oct-2020 09:28:49

10K+ Views

There are multiple files and folders attribute supported by the Windows Operating System. To check which attributes that files and folders support use DOS command attrib /?You can see the attributes listed like Read-Only, Archive, etc. You can set the attribute using PowerShell.For example, we have a file called TestFile.txt and its attribute is ReadOnly and we need to change it to the Archive.PS C:\> (Get-ChildItem C:\Temp\TestFile.txt).Attributes ReadOnlyChange Attribute code −$file = Get-ChildItem C:\Temp\TestFile.txt $file.Attributes = 'Archive'So we have set the attribute to the ‘Archive’ from ‘ReadOnly’ and when you check it, the attribute should be changed.PS C:\> (Get-ChildItem C:\Temp\TestFile.txt).Attributes ... Read More

How to retrieve files and folders attributes using PowerShell?

Chirag Nagrekar
Updated on 16-Oct-2020 09:20:11

3K+ Views

To retrieve files and folders attributes using PowerShell, you can use Get-Item or Get-ChildItem command. For example, We have a file called testfile.txt to get its attributes, PS C:\> Get-ChildItem C:\Temp\TestFile.txt |Select Name, Attributes Name Attributes ---- ---------- TestFile.txt ArchiveSo this file has the Archive attribute. To retrieve multiple files and folders' attributes, just refer to the folder name instead of the file name.Get-ChildItem C:\Temp -Recurse -Force | Select Name, FullName, Attributes Name ... Read More

How to get hidden files and folders using PowerShell?

Chirag Nagrekar
Updated on 05-Oct-2020 11:29:24

13K+ Views

To get hidden files and folders using PowerShell, we need to use the Get-ChildItem command with the - Hidden or -Force parameter.The difference between the two mentioned parameters is Hidden parameter only retrieves the hidden files and folders while the Force parameter retrieves all the files and folders including Hidden, read-only and normal files and folder.For example, We have one folder named Data inside folder C:\temp and we need to retrieve it.PS C:\> Get-ChildItem C:\Temp\ -Hidden Directory: C:\Temp Mode        LastWriteTime      Length Name ----        -------------     ------ ---- d--h-       ... Read More

How to remove pagefile on the specific drive using PowerShell?

Chirag Nagrekar
Updated on 05-Oct-2020 11:22:57

3K+ Views

In this article, we have a pagefile set on E: (System managed) and we need to remove the pagefile from E: So in the below image once we remove it, the pagefile should be “No Paging File”.To do so using PowerShell, we need to filter the pagefile on a specific drive and need to run the below code.$pagefileset = Gwmi win32_pagefilesetting | where{$_.caption -like 'E:*'} $pagefileset.Delete()You may want to reboot the server after removing pagefile.To change the above settings on the remote computer, use -ComputerName parameter in the GetWMIObject class.

How to change pagefile settings from custom to system managed using PowerShell?

Chirag Nagrekar
Updated on 05-Oct-2020 11:20:44

923 Views

To change the pagefile settings to system managed, we need to set InitialSize and MaximumSize parameters to 0. In the below example, we have E: has custom pagefile, not system managed and we need to convert it to the system managed.$pagefileset = Gwmi win32_pagefilesetting | where{$_.caption -like 'E:*'} $pagefileset.InitialSize = 0 $pagefileset.MaximumSize = 0 $pagefileset.Put() | Out-NullNow when you check the pagefile setting on E: it should be System managed.To change the settings on the remote computer use -ComputerName parameter in the Get-WmiObject method.

How to change Pagefile settings using PowerShell?

Chirag Nagrekar
Updated on 05-Oct-2020 11:18:47

11K+ Views

To change the pagefile settings, we will divide this into multiple sections. First, when Pagefile is automatically managed, we can’t modify the settings so we need to remove that box. In GUI that box can be unchecked in Virtual memory settings.Code to uncheck the above box.$pagefile = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges $pagefile.AutomaticManagedPagefile = $false $pagefile.put() | Out-NullSo once the above code is executed, other fields will be enabled. We now need to Customize the size of the pagefile in the below image by providing Initial and Maximum size using PowerShell.Here we have already the pagefile on the C: while on the ... Read More

How to get pagefile settings using PowerShell?

Chirag Nagrekar
Updated on 05-Oct-2020 11:32:59

10K+ Views

Pagefile also Known as Virtual Memory file in the Windows Operating system is a very useful part of the OS. It helps to reduce the burden on the Physical memory by storing some paging file in the file call Pagefile.sys. Generally, this file in windows OS is stored in C:\ unless it is modified.You can check the Pagefile settings in the Windows GUI usingSystem Properties → Advanced → Performance → Settings → Advanced → Virtual Memory → Change.We have made a few blocks and circles in the above pagefile properties image. We will see them one by one.First, to check ... Read More

How to Set environment variables using PowerShell?

Chirag Nagrekar
Updated on 29-Aug-2023 07:24:55

276K+ Views

To set the environmental variable using PowerShell you need to use the assignment operator (=). If the variable already exists then you can use the += operator to append the value, otherwise, a new environment variable will be created.For example, there is no AZURE_RESOURCE_GROUP environment variable that exists in the system. We can create it as below.$env:AZURE_RESOURCE_GROUP = 'MyTestResourceGroup'Now when you check the environment variables in the system, you will get the above variable name.PS C:\Windows\system32> dir env: Name                            Value ----             ... Read More

How to get environment variable value using PowerShell?

Chirag Nagrekar
Updated on 31-Oct-2023 13:31:58

87K+ Views

Environment variables are an essential part of the Operating System. They store various information like the path of the system files and folders, the number of processors system running, current user details, and more. Processes and programs utilize these environment variables to retrieve the data for their execution.Environment variables in PowerShell are stored as PS drive (Env: ). To retrieve all the environment variables stored in the OS you can use the below command.Get-ChildItem -Path Env:Name                        Value ----                       ... Read More

How to disable windows firewall profiles using PowerShell?

Chirag Nagrekar
Updated on 28-Sep-2020 08:37:52

1K+ Views

There are 3 types of profiles that firewall supports. a) Domain b) Public and c) Private profile. You can check the same settings using the GUI in the Windows Firewall Advanced Security settings window as shown below.You can check the above settings using the Get-NetFirewallProfile command.Get-NetFirewallProfile | Select Name, Enabled Name Enabled ---- ------- Domain True Private True Public TrueTo turn off or disable the above profiles using PowerShell, you need to use the command Set-NetFirewallProfile.To disable the specific profile, use -Profile parameter. You can pass 3 different profile ... Read More

Advertisements