Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Software & Coding Articles
Page 64 of 83
How to open a port in the Windows Operating System using PowerShell?
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 MoreHow to change files and folders attributes using PowerShell?
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 MoreHow to retrieve files and folders attributes using PowerShell?
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 MoreHow to get pagefile settings using PowerShell?
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 MoreHow to remove pagefile on the specific drive using PowerShell?
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.
Read MoreHow to change pagefile settings from custom to system managed using PowerShell?
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.
Read MoreHow to disable windows firewall profiles using PowerShell?
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 MoreHow to get windows firewall profile settings using PowerShell?
Recent windows client and server operating systems like Windows 10, Windows Server 2008 onwards, supports advanced firewall versions and they have mainly 3 profiles.DomainPublicPrivate profile.To get the setting using GUI, you need to search in the box Windows Firewall with Advanced Security or Windows Defender Firewall with Advanced Security. Then you can see in the console that 3 available profiles.The above same settings can be viewed with the PowerShell Get-NetFirewallProfile command.PS C:\> Get-NetFirewallProfile Name : Domain Enabled : True DefaultInboundAction : NotConfigured DefaultOutboundAction : NotConfigured AllowInboundRules : NotConfigured AllowLocalFirewallRules : NotConfigured AllowLocalIPsecRules : NotConfigured AllowUserApps : NotConfigured AllowUserPorts : NotConfigured ...
Read MoreHow to check if remote ports are open using PowerShell?
Earlier days we were using telnet clients to check the remote port connectivity, in fact, we are still using it with cmd and PowerShell but this feature is not by default installed in OS and some companies have restrictions on installing new features including telnet.We can leverage PowerShell to test remote port connectivity without installing telnet and with the use of the Test-NetConnection command. This command is also very useful for other diagnostics but we are focusing here for the remote port check.To check if the remote port is open or not we can use the Test-NetConnection command and it ...
Read MoreHow to Copy NTFS permissions using PowerShell?
To change, add or remove security permissions on the files or folder using PowerShell you can use the Set-Acl command. The best way to set the permission is to copy the permissions from another file or folder if you need the same permissions on the destination path.For example, I want the same folder permissions of the source C:\Shared\ to the destination folder path c:\shared1 path. You can use any destination path, it could be the remote shared UNC path.See the difference in the above security permissions, the Shared named folder has one additional permission assigned (LABDOMAIN\Delta). We will copy the ...
Read More