In CMD, use attrib +AttributeType filename to add an attribute or attrib -AttributeType filename to remove an attribute from a file, where AttributeType could be R (read-only), H (hidden), S (system), or A (archive). In PowerShell, use Get-Item "filename" | Set-ItemProperty -Name Attributes -Value "ReadOnly, Hidden" to manage file attributes in a more structured manner.