NIC error modern UI – Windows cannot access specified device, path, or file. You may not have the appropriate permissions to access the item. Solution: In an elevated command prompt, run gpedit.msc Go to Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options Open “User Account Control: Admin Approval Mode […]
Author: Jan Ryen
Automate set up of first Active Directory DC with powershell
In my lab, I often have the need to quickly set up various servers from scratch. One type of server is an Active Directory Domain Controller. So I slapped together a simple script to completely automate (light touch) the process of setting up a complete AD DC in a new forest. I also did the […]
What to memorize
Albert Einstein is claimed to once have said that he keeps nothing in his mind that can be easily retrieved from paper – or looked up. As far as I’m concerned, you should not memorize most things but instead memorize where and how to quickly find the required information and how to use it. Also, […]
Get Network card driver version remotely
|
1 2 3 4 5 6 7 8 9 10 11 12 |
# Get Network card driver version remotely and only for a specific vendor $cred = Get-Credential domain\user Invoke-Command -Credential $cred -ScriptBlock {Get-WmiObject Win32_PnPSignedDriver -Filter "DeviceClass = 'NET'" | Where-Object devicename -Match qlogic | ft DeviceName,DriverVersion} -ComputerName computernamehere #sample output: #DeviceName DriverVersion #---------- ------------- #QLogic FastLinQ QL45412H 40GbE Adapter (VBD Client) 8.37.6.0 #QLogic FastLinQ QL45412H 40GbE Adapter (VBD Client) 8.37.6.0 #QLogic FastLinQ QL45412H 40GbE Adapter (VBD Client) 8.37.6.0 #QLogic FastLinQ QL45412H 40GbE Adapter (VBD Client) 8.37.6.0 |
Share folder with PowerShell
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
<# .SYNOPSIS Create a folder, share it and set permissions for several users or groups .DESCRIPTION Create a folder, share it and set permissions for several users or groups .NOTES File Name : Create-Share.ps1 Author : Jan Ryen (jan@janryen.com) Copyright 2019 - Jan Ryen #> # Which directory do you want the shared folder to be created in $pathname = "D:\Shares" # What is the name of the folder to be created and shared $foldername = "TestFolder" # Set path to be used in Set-Acl $fullpath = "$pathname\$foldername" # Create folder New-Item $fullpath –type directory #Create share and share permissions New-SmbShare -Name "$foldername" -Path $fullpath -CachingMode None -FullAccess "Everyone" #remove NTFS ACL inheretance and leave inherited permissions in place #icacls.exe $fullpath /inheritance:d $acl = Get-Acl $fullpath $acl.SetAccessRuleProtection($true,$true) $acl | Set-Acl $fullpath #Purge unwanted User Permissions # usually a good idea to get rid of CREATOR OWNER and BUILTIN\Users $acl = Get-Acl $fullpath $usersid = New-Object System.Security.Principal.Ntaccount ("CREATOR OWNER") $acl.PurgeAccessRules($usersid) $acl | Set-Acl $fullpath $acl = Get-Acl $fullpath $usersid = New-Object System.Security.Principal.Ntaccount ("BUILTIN\Users") $acl.PurgeAccessRules($usersid) $acl | Set-Acl $fullpath #Define inheretance $InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit $PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None $acType = [System.Security.AccessControl.AccessControlType]::Allow #foreach $fullControllUsers = "TEST\user1", "TEST\group1" $modifyUsers = "TEST\group2", "TEST\group3", "TEST\group4" foreach ($item in $fullControllUsers) { # add FullControl users $acl = Get-Acl $fullpath $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($item,"FullControl", $InheritanceFlag, $PropagationFlag, $acType) $acl.SetAccessRule($AccessRule) $acl | Set-Acl $fullpath } foreach ($item in $modifyUsers) { # add Modify users $acl = Get-Acl $fullpath $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($item, "Modify", $InheritanceFlag, $PropagationFlag, $acType) $acl.SetAccessRule($AccessRule) $acl | Set-Acl $fullpath } #check what we have now Get-Acl $fullpath | Format-Table -Wrap |
Start SCCM WSUS IIS pool with PowerShell
Some times the WSUS server on SCCM can stop. If the WSUSPool in IIS Application pools is stopped, WSUS will not function and SCCM will not update any clients. In anticipation of further troubleshooting, here is a workaround script to check the Application Pool and start it if it is not running. This script can […]