- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2043 Articles for Microsoft Technologies
3K+ Views
To block the port using PowerShell on the Windows OS, we need to change the firewall settings using the New-NetFirewallRule command.ExampleWe need to block the port 5985 on the computer. The below code will block all TCP Incoming requests on the 5985 port on the local computer.New-NetFirewallRule -DisplayName "Block WINRM HTTP Port" ` -Direction Inbound ` -LocalPort 5985 ` -Protocol TCP ` -Action Block To ... Read More
2K+ Views
To open a port in the Windows Operating system, we need to know a few things. LikeFor which Profile we need to open port (Public, private, or Domain)? - OptionalWhich port do we need to open (port Number)?The direction of the port – Inbound (i.e Incoming requests) or Outbound (i.e. Outgoing requests).Protocol by name (TCP, UDP, ICMPv4, or ICMPv6) or Number (0-255).Once we have all the details we can open the port. In the below example, we need to open a port 5985 (WINRM HTTP) port on the computer which is currently blocked. So we will use the below command.New-NetFirewallRule -DisplayName "Allow WINRM HTTP Port" ` ... Read More
8K+ 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
2K+ 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
11K+ 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
2K+ 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.
531 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.
8K+ 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
7K+ 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
218K+ 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