PowerShell for Hyper-V: Avoid Error Running PowerShell Scripts

Hyper-VThis post is part of the series on PowerShell for Hyper-V.

If you try to run a PowerShell script, you will receive an error:

PowerShell error trying to run script

File C:TempResume HVVMs.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at 
https:/go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess

This is deliberate on Microsoft’s part to make sure a script is not inadvertently run. You can enable running of scripts, but this is very risky.

However, there is a command you can run which will, for only the script being run, allow the script to run (replace the highlighted section with your script file):

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File {your script}

The relevant section is

-ExecutionPolicy Bypass

which tells PowerShell that it may bypass the execution policy restriction.

Edge Canary: Download

Edge CanaryMicrosoft have recently announced they are ditching the current version of their Edge browser in favour of a Chromium based browser. In this series, I am going to take a look at the Canary version of this new browser.

Downloading Edge Canary is easily done from the Microsoft Edge Insider site by clicking the blue button for the desired channel; I am using the Canary Channel:

Download Canary Channel

Continue reading “Edge Canary: Download”

PowerShell for Hyper-V: Series Index

Hyper-VWhen I joined ISC Software Solutions I received a new work laptop. This gave me both the need and, importantly, the time to get everything setup as I need it. This included creating new demo VMs to use.

In the past, I had one VM for each version with everything installed. This time round I have created two VMs, one hosting a Domain Controller and the other a SQL Server, which I will then use with a version based server.

To make things a little easier, I have created some PowerShell scripts to handle the VMs. This is a short series of posts for the scripts I have (none of them are complex, but I’m posting them here for easy access.

Continue reading “PowerShell for Hyper-V: Series Index”

Edge Canary: Why Is Edge Being Remade In Chromium?

Edge CanaryMicrosoft have recently announced they are ditching the current version of their Edge browser in favour of a Chromium based browser. In this series, I am going to take a look at the Canary version of this new browser.

The Microsoft Edge browser launched a few years ago to replace Internet Explorer, bit is now itself being replaced with a Chromium based version. Microsoft announced this in December last year:

For the past few years, Microsoft has meaningfully increased participation in the open source software (OSS) community, becoming one of the world’s largest supporters of OSS projects. Today we’re announcing that we intend to adopt the Chromium open source project in the development of Microsoft Edge on the desktop to create better web compatibility for our customers and less fragmentation of the web for all web developers.

As part of this, we intend to become a significant contributor to the Chromium project, in a way that can make not just Microsoft Edge — but other browsers as well — better on both PCs and other devices.

The reason for the change appears to be the cost of maintaining their own rendering engine, which was the same logic applied by Opera a few years ago when they ditched their Presto engine and moved to Chromium (it also saw them dump 99% of the features of a web browser including bookmarks, which they have slowly been adding back).

This move by Microsoft means that the Internet is now going to be dominated by Chromium based browsers (Chrome, Edge, Opera, Vivaldi, Brave amongst others) with Firefox and Safari playing increasingly small supporting roles.

Despite talk by Microsoft of collaborating directly with Google and others for contributing to the open source project, there are concerns that the Internet will be heading back to the bad old days of IE6 where one browser dominated to the detriment of the Internet; Firefox has expressed concerns along these lines.

There have already been browser specific tags and CSS created as companies decide to interpret the HTML specification differently, or advance beyond what has been finalised. This has made developing for the Internet more complex as you need to code for different rendering engines. From one perspective, Microsoft using Chromium will simplify development, but long-term browser lock in and ignoring of standards becomes more likely.

Only time will tell if these concerns come to fruition; unfortunately, if they do, it will be too late and we will be locked into an Internet dominated and effectively controlled by one browser.

Edge Canary
What Is Edge Canary?
Why Is Edge Being Remade In Chromium?
Download
Installation
Add Extension From Microsoft Store
Add Extension From Chrome Play Store
Dark Mode

Edge Canary: What Is Edge Canary?

Edge CanaryMicrosoft have recently announced they are ditching the current version of their Edge browser in favour of a Chromium based browser. In this series, I am going to take a look at the Canary version of this new browser.

Microsoft Edge is currently in development and has two “channels” currently available:

  1. Dev Channel, which is updated weekly. The dev builds are the best representation of the improvements in the past week. They have been tested by the Microsoft Edge team, and are generally more stable than Canary.
  2. Canary Channel, which is updated daily. Want to see what Microsoft were working on yesterday? Canary will be released automatically almost every night to keep you up to date on Microsoft’s progress.

As development progresses, a Beta Channel, which updates every six weeks, will become available. This channel will be the most stable Microsoft Edge preview experience. It will be here soon, after we’ve had a chance to learn and improve in our other channels.

For this series, I’ve opted for the Canary Channel.

Run Application Error Generating Remittances

Microsoft Dynamics GPI was onsite with a client a while ago helping them create new Citrix XenApp Gold Build Servers. When users were testing, they encountered the following error when generating remittances:

Run application error message

RUN APPLICATION ERROR

"C:UsersTEMP~1.FLAppDataLocalTempCheck Remittance~2.docx" '
returned 5

Continue reading “Run Application Error Generating Remittances”

Hyper-V: ‘The requested operation could not be completed due to a file system limitation’

Hyper-VWhen I joined ISC Software I received a new laptop which was pretty much a blank slate except for Windows itself. This meant that I had to install and configure everything I needed (I prefer this as it means I can configure everything exactly as I want it).

Due to having an SSD, instead of an HDD, in the laptop, I also got an external SSD which I am using for hosting my virtual machines using Hyper-V.

I thought nothing of this, but when I tried to start a VM from the external SSD, I received the following error:

Hyper-V Manager error

...Failed to power on with the Error 'The requested operation could not be completed due to a file system limitation'.

I double checked the external SSD and discovered it had a File System of exFAT; I reformatted the SSD into NTFS copied the virtual hard disks back onto it and was able to successfully start the virtual machine.

PowerShell to Promote Domain Controller

Windows ServerWhen testing Microsoft Dynamics GP, I often need a domain controller within my set of virtual machines. I’ve been promoting a server to be a domain controller manually, but it recently occurred to me that I could probably do the same task using PowerShell.

After doing some research, I came up with four commands which will rename and restart the server, install the Active Directory feature and add a forest.

To rename a server, run the following command, replacing the highligted section with the new server name:

Rename-computer -newname {server name}

Continue reading “PowerShell to Promote Domain Controller”

SQL Stored Procedure to Generate Sequential Number

Microsoft SQL ServerWhile much of the work I do is directly with Microsoft Dynamics GP, I also do work for clients which isn’t directly related. I’ve created code to generate numbers a few times in the past and figured I might as well post the base code I use for this to make it easier to find in future.

I’ve created it in such a way that several unique numbers can be stored and incremented.

The first part of the code creates a table to hold the number type and next number:

-- drop table if it exists
IF OBJECT_ID (N'ut_AZRCRV_NextNumber', N'U') IS NOT NULL
	DROP TABLE ut_AZRCRV_NextNumber
GO
-- create table
CREATE TABLE ut_AZRCRV_NextNumber(
	NMBRTYPE VARCHAR(50)
	,NEXTNMBR INT
)
GO

Next, I create a stored procedure which will increment and return the next number:

-- drop stored proc if it exists
IF OBJECT_ID (N'usp_AZRCRV_GetNextNumber', N'P') IS NOT NULL
    DROP PROCEDURE usp_AZRCRV_GetNextNumber
GO
-- create stored proc
CREATE PROCEDURE [dbo].[usp_AZRCRV_GetNextNumber]
	(
	@NMBRTYPE VARCHAR(50)
	,@NEXTNMBR INT OUTPUT
	)
AS
/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
SET NOCOUNT ON BEGIN TRAN -- if this is the first value generated for this table, start with one IF NOT EXISTS (SELECT * FROM ut_AZRCRV_NextNumber WHERE NMBRTYPE = @NMBRTYPE) INSERT INTO ut_AZRCRV_NextNumber (NMBRTYPE,NEXTNMBR) VALUES (@NMBRTYPE,1) -- select next number from table into variable SELECT @NEXTNMBR = NEXTNMBR FROM ut_AZRCRV_NextNumber WHERE NMBRTYPE = @NMBRTYPE -- increment number by 1 UPDATE ut_AZRCRV_NextNumber SET NEXTNMBR = NEXTNMBR + 1 WHERE NMBRTYPE = @NMBRTYPE COMMIT TRAN -- return variable containing next number RETURN @NEXTNMBR GO

Then, I grant execute permissions to the relevant database role:

-- grant execute permission on stored proc to ur_AZRCRV_InvoiceUser
GRANT EXECUTE ON usp_AZRCRV_GetNextNumber TO ur_AZRCRV_InvoiceUser
GO

And finally, I have the SQL code which will generate the next number:

-- code to get next number
DECLARE @NMBRTYPE VARCHAR(50) = 'Sales Invoice'
DECLARE @NEXTNMBR INT

EXEC [usp_AZRCRV_GetNextNumber] @NMBRTYPE, @NEXTNMBR OUTPUT

SELECT @NEXTNMBR
GO

Add Company Access Back to sa User

Microsoft Dynamics GPWe’re busy doing some work for a client for whom we’ve recently taken over the support of their Microsoft Dynamics GP implementation. For the initial set of projects, we’re assisting them in the creation of a standalone test systemm. When you do this, the first thing you need to do is log in using the sa account and reset passwords.

However, we found that at some point in the past, all company access had been removed from the sa user account leaving us unable to log into Dynamics GP.

Fortunately, company access is only stored within one table in the system database: User-Company Access (SY60100).

The SQL below will add company access back to the sa user for all company databases:

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (http://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
INSERT INTO SY60100
	(TRKUSER,USERID,CMPANYID,SRBCHSEC_1,SRBCHSEC_2,SRBCHSEC_3,SRBCHSEC_4,SRBCHSEC_5,SRBCHSEC_6,SRBCHSEC_7,SRSFNSEC_1,SRSFNSEC_2,SRSFNSEC_3,SRSFNSEC_4,SRSFNSEC_5,SRSFNSEC_6,SRSFNSEC_7,MSCPRMIS)
--VALUES
	(
	SELECT
		0,'sa',CMPANYID,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF
	FROM
		SY01500 AS ['Company Master']
	WHERE
		(
		SELECT
			COUNT(*)
		FROM
			SY60100 AS ['User-Company Access']
		WHERE
			['User-Company Access'].CMPANYID = ['Company Master'].CMPANYID
		AND
			['User-Company Access'].USERID = 'sa'
		) = 0
	)
GO

After you’ve run the above to add company access back, you also need to run the SQL insert statement in this post to add POWERUSER access as well.

With the two scripts run, the sa account can be used to reset the DYNSA user and other user accounts.