• Please provide powershell reboot script for multiple machines with 2alert options along with force reboot.

  • Very good blog and helpful. Similarly how can we select folder path instead of file?? 

    Thanks in Advance 🙂

     

  • "Group Policy Preferences and Setting the Default Printer

    On a final note, you may encounter some guides that recommend the use of Group Policy Preferences for printer deployment instead, and in some scenarios that method does have advantages. However it is more complicated to manage and does not integrate with the Print Management console, hence why I prefer the standard Group Policy. There is one particular situation where they can be particularly useful though, which is when you need to set users’ default printer, but that is something to be covered in a separate article."

    Text extracted from: https://www.petri.com/deploying-printers-using-group-policy-windows-2008

  • David, easy to understand and very well explained with examples. Thanks!

    How can i export the results from an [pscustomobject] to a log file ( ie ExportCs,etc. Export-Csv prompt me for an InputObject)

  • David, easy to understand and very well explained with examples. Thanks!

    How can i export the results from a [pscustomobject] to a log file ( ie ExportCs,etc. Export-Csv prompt me for an InputObject)

  • This works a treat, thank you very much!

  • Love it but hate it. I haven't figured out how to get this to be successful for an IIS web cert.

  • The guy before me had the VM  and FW configured wink

  • Let`s say you just got there and have no time to start making other adjustments, GPO`s and other things.

    As for the FW thing, I prefer to have a VM for administration purposes so all the ports needed are open.

    My script simply works , dirty, but works, for sure I could make it better , but for now it just fill`s the need.

    Feel free to make it better and share it . Thank You.

  • Leos, thanks for your response. Once enabling that on the remote machine, it worked! I'm assuming PSRemoting should be disabled as it could be a security risk?

  • #Computers to install fonts to
    $ComputerArray = @("Pc1","Pc2","Pc3")
    #A Share containing only the fonts you want to install
    $FontDir="FileServerSharesHelpdeskSpecialFonts"
    #Wil be created on remote Pc if not exists, fonts will be copied here and deleted after install.
    $PcStagingDir="c:tools"
    
    foreach ($pc in $ComputerArray) {
    $RemotePcStagingDir = "$pc$($PcStagingDir.replace(':','$'))"
    If(Test-Connection -ComputerName  $pc -Count  1 -ErrorAction SilentlyContinue) {
    $DisabledSvcs=@()
    $ServiceName = @("WinRM")
    foreach ($svc in $ServiceName) {
            $i=0
            while(((Get-Service -ComputerName $pc -Name $svc -ErrorAction SilentlyContinue).status -ne "Running")-and($i -lt 10)){
                if((Get-Service -ComputerName $pc -Name $svc -ErrorAction SilentlyContinue).StartType -eq "Disabled"){
                Write-Host "Try $i , Setting service $svc StartType to Manual on $pc ..."
                $DisabledSvcs+=$svc
                Set-Service -ComputerName $pc -Name $svc -StartupType Manual -ErrorAction SilentlyContinue}
            Write-Host "Try $i / 10 , Starting $svc Service on $pc ..."
            $commandz="sc "+$pc +" Start "+$svc
            & cmd.exe /c $commandz | Out-Null
            $i++
            sleep 3}
            if($i -ge 10){break}
        }
    if($i -ge 10){Write-Host "Could NOT start service $svc, Skipping Computer $pc" -ForegroundColor Red}else{
    New-Item -Path $RemotePcStagingDir -ItemType Directory -Force -ErrorAction SilentlyContinue
    if($RemoteWinDir=Invoke-Command -ComputerName $pc -ScriptBlock {return $env:windir} -ErrorAction SilentlyContinue){
    foreach($FontFile in (Get-ChildItem -file -path $FontDir)){
        if(-not(Test-Path "$pc$($RemoteWinDir.replace(':','$'))Fonts$FontFile")){
            Copy-Item "$FontDir$FontFile" -Destination $RemotePcStagingDir -Force
            Invoke-Command -ComputerName $pc -ScriptBlock {
           $filePath="$using:PcStagingDir$using:FontFile"
           $fontRegistryPath = "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionFonts"
           $fontsFolderPath = "$($env:windir)fonts"
        # Create hashtable containing valid font file extensions and text to append to Registry entry name.
        $hashFontFileTypes = @{}
        $hashFontFileTypes.Add(".fon", "")
        $hashFontFileTypes.Add(".fnt", "")
        $hashFontFileTypes.Add(".ttf", " (TrueType)")
        $hashFontFileTypes.Add(".ttc", " (TrueType)")
        $hashFontFileTypes.Add(".otf", " (OpenType)")
        try
        {
            [string]$filePath = (Get-Item $filePath).FullName
            [string]$fileDir  = split-path $filePath
            [string]$fileName = split-path $filePath -leaf
            [string]$fileExt = (Get-Item $filePath).extension
            [string]$fileBaseName = $fileName -replace($fileExt ,"")
    
            $shell = new-object -com shell.application
            $myFolder = $shell.Namespace($fileDir)
            $fileobj = $myFolder.Items().Item($fileName)
            $fontName = $myFolder.GetDetailsOf($fileobj,21)
            
            if ($fontName -eq "") { $fontName = $fileBaseName }
    
            copy-item $filePath -destination $fontsFolderPath
    
            $fontFinalPath = Join-Path $fontsFolderPath $fileName
            if (-not($hashFontFileTypes.ContainsKey($fileExt))){Write-Host "File Extension Unsupported";$retVal = 0}
            if ($retVal -eq 0) {
                Write-Host "Font `'$($filePath)`'`' installation failed on $env:computername" -ForegroundColor Red
                Write-Host ""
                1
            }
            
            else
            {
                Set-ItemProperty -path "$($fontRegistryPath)" -name "$($fontName)$($hashFontFileTypes.$fileExt)" -value "$($fileName)" -type STRING
                Write-Host "Font `'$($filePath)`' $fontName $($hashFontFileTypes.$fileExt) installed successfully on $env:computername" -ForegroundColor Green
            }
    
        }
        catch
        {
            Write-Host "An error occured installing `'$($filePath)`' on $env:computername" -ForegroundColor Red
            Write-Host "$($error[0].ToString())" -ForegroundColor Red
            $error.clear()
        }
        }
         }
         Remove-Item "$RemotePcStagingDir$FontFile" -ErrorAction SilentlyContinue
    }
    Write-Host "Done working on Remote Pc $pc" -ForegroundColor Green
    }else{Write-Host "Could not Invoke-Command to Remote Pc $pc" -ForegroundColor Red}
    }
    foreach($DisabledSvc in $DisabledSvcs){
        Write-Host "Setting service $DisabledSvc StartType to Disabled on $pc ..."
        Set-Service -ComputerName $pc -Name $DisabledSvc -StartupType Disabled -ErrorAction SilentlyContinue
        $commandz="sc "+$pc +" Stop "+$DisabledSvc
        & cmd.exe /c $commandz | Out-Null
    }
    }Else{Write-Host "No Connection to WinRM service on Remote Pc $pc" -ForegroundColor Red}
    }

     

  • Alan,

    Thanks for sharing. I like your script better than the one in the article as it will pull multiple font types but I'm getting issues remotely connecting to machines. Your script appears to turn on the WinRM service remotely but doesn't seem to work for me in my environment. I'm getting "No Connection to WinRM service on Remote Pc". Any suggestions?

  • "How to Extend Your Office 2013 Trial to 180 Days"

    1. Navigate to C:Program Files

    2. Now find and open folder Microsoft Office

    3. Then go to folder called Office15

    4. Finally run file called OSPPREARM.exe as Administrator

    All done. You can rearm five times - Installation (30 days) 5 rearms adds 150 days, total 180 days.

  • I am running into the same issue.  Any solutions for this?

  • Hi,

    Can i schedule powershell script which queries MSOL service using powershell jobs.

    i tried same with task scheduler however it doesnt work does not matter how many things i have:

    passing credential via a secured file.

    running with highest privileges and run even if user logged on or off setting.

    still same. it shows in history that run is completed however no result.

    the same script runs fine if i run it using powershell ISE manually.

    please help...

     

  • This is very helpful.  Thank you so much.  Stock Microsoft WSUS reporting will make you cry.

  • Is it possible to run a windows 2019 server eval and then register it with VLSC MAK License? 

  • Yes, you can:

    do {$a = $a + 1} while ($a -eq 2 -or $a -eq 3 -or $a -eq 4)

    You will end up with 5.

  • How do I make this ask for a specific username/name first so that way it'll only show the entered ID's information

  • Load More